[Решено]Скрипт ХелфБара не работает *я отчаялся*

Программирование на Юнити.

[Решено]Скрипт ХелфБара не работает *я отчаялся*

Сообщение darkdeaf 08 июн 2011, 15:55

Скрипт HealthBar'a
Скрипт на С Sharp Script Делал на MonoDevelop
Буду крайн благодарен за исправленный скрипт!
Код: Выделить всё
using UnityEngine;
using System.Collections;

public class PlayerHealth : MonoBehaviour {
   
   public int maxHealth = 100;
   
   private int _ourHealth = 100;
      
    private float healthBarLenght;
   
   void Start () {
      AddjustCorrentHealth(_curHealth);
      HealthBarLenght = Screen.width /2;

      _curHealth = maxHealth;
      
   }
   
   void Update () {
   AddjustCorrentHealth(_curHealth);
   }
   
   void OnGUI () {
   
      GUI.Box(new Rect(10,10,healthBarLenght,20),_curHealth + "/" + maxHealth);
   }
   
   public void AddjustCorrentHealth (int adj){
      _curHealth = adj;
      if(_curHealth<0) _curHealth = 0;
      if(_curHealth>maxHealth) _curHealth = maxHealth;
      healthBarLenght = (Screen.width /2) * (_curHealth / (float)maxHealth);
   }
}
}

ОШИБКИ
Код: Выделить всё
Assets/PlayerHealth.cs(13,37): error CS0103: The name `_curHealth' does not exist in the current context
Assets/PlayerHealth.cs(13,17): error CS1502: The best overloaded method match for `PlayerHealth.AddjustCorrentHeath(int)' has some invalid arguments
Assets/PlayerHealth.cs(13,17): error CS1503: Argument `#1' cannot convert `object' expression to type `int'
Assets/PlayerHealth.cs(14,17): error CS0103: The name `HealthBarLenght' does not exist in the current context
Assets/PlayerHealth.cs(16,30): error CS0103: The name `maxHeath' does not exist in the current context
Assets/PlayerHealth.cs(16,17): error CS0103: The name `_curHealth' does not exist in the current context
Последний раз редактировалось darkdeaf 08 июн 2011, 17:13, всего редактировалось 2 раз(а).
darkdeaf
UNец
 
Сообщения: 4
Зарегистрирован: 08 июн 2011, 15:52

Re: Скрипт ХелфБара не работает *я отчаялся*

Сообщение darkdeaf 08 июн 2011, 16:02

Ошибки в синтаксисе исправил но все равно не прет [curved_hands]
darkdeaf
UNец
 
Сообщения: 4
Зарегистрирован: 08 июн 2011, 15:52

Re: Скрипт ХелфБара не работает *я отчаялся*

Сообщение Avatarchik 08 июн 2011, 16:43

Держи: :D

Синтаксис:
Используется csharp
using UnityEngine;
using System.Collections;

public class PlayerHealth : MonoBehaviour {
   
   public int maxHealth = 100;
   public int _curHealth;
   private int _ourHealth = 100;
     
    private float healthBarLenght;
   
   void Start () {
      AddjustCorrentHealth(_curHealth);
      healthBarLenght = Screen.width /2;

      _curHealth = maxHealth;
     
   }
   
   void Update () {
   AddjustCorrentHealth(_curHealth);
   }
   
   void OnGUI () {
   
      GUI.Box(new Rect(10,10,healthBarLenght,20),_curHealth + "/" + maxHealth);
   }
   
   public void AddjustCorrentHealth (int adj){
      _curHealth = adj;
      if(_curHealth<0) _curHealth = 0;
      if(_curHealth>maxHealth) _curHealth = maxHealth;
      healthBarLenght = (Screen.width /2) * (_curHealth / (float)maxHealth);
   }
}
Добавить ava-karaban в Skype
Аватара пользователя
Avatarchik
UNITрон
 
Сообщения: 274
Зарегистрирован: 04 апр 2009, 15:36
Откуда: Украина(Донецк)
  • ICQ

Re: Скрипт ХелфБара не работает *я отчаялся*

Сообщение darkdeaf 08 июн 2011, 16:50

ОГРОМНОЕ вам спасибо (3A4OT)
darkdeaf
UNец
 
Сообщения: 4
Зарегистрирован: 08 июн 2011, 15:52

Re: [Решено]Скрипт ХелфБара не работает *я отчаялся*

Сообщение seaman 08 июн 2011, 17:28

Avatarchik
Зачем Вы портите человека. Он настолько ленив, что похоже распознавал скрипт в Файнридере со скрина урока. Иначе просто не объяснить такое количество описок. Вы собираетесь ему все скрипты исправлять? Если он не научится сам писать, то придется...
seaman
Адепт
 
Сообщения: 8352
Зарегистрирован: 24 янв 2011, 12:32
Откуда: Самара

Re: [Решено]Скрипт ХелфБара не работает *я отчаялся*

Сообщение ArtUni3d 08 июн 2011, 18:59

Это же с видео туториала. Переписать что-ли нельзя?
Аватара пользователя
ArtUni3d
UNITрон
 
Сообщения: 249
Зарегистрирован: 27 апр 2011, 22:12


Вернуться в Скрипты

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 6