Показать сообщение отдельно
Старый 09.04.2013, 10:38   #5
SGREED
ПроЭктировщик
 
Аватар для SGREED
 
Регистрация: 05.02.2013
Сообщений: 149
Написано одно полезное сообщение
Ответ: Падение игрока с высоты

мой скрипт здоровья и отрисовка
using UnityEngine;
using System.Collections;

public class 
PlayerHealth : MonoBehaviour {
    
    public 
int maxHealth;
    public 
int _curHealth;
    public 
float healthBarLength;

    
// Use this for initialization
    
void Start () {
    
healthBarLength = Screen.width /4;
        if(
maxHealth<1) maxHealth=1;
    }
    
    
// Update is called once per frame
    
void Update () {
        
    }
    
void OnGUI(){
        
GUI.Box(new Rect(10,10,healthBarLength,20),_curHealth + "/" +maxHealth);
    }
        public 
void AddjustCurrentHealth( int adj) {
            
_curHealth += adj;
            if(
_curHealth < 0) _curHealth =0;
        if(
_curHealth < 1) Destroy(gameObject);
            if(
_curHealth > maxHealth) _curHealth = maxHealth;
            
healthBarLength = (Screen.width / 4) * (_curHealth / (float)maxHealth);
    }
} 
и в этот скрипт надо правильно вписать падение, а я с физикой сильно не сталкивался и поэтому незнаю=(
(Offline)
 
Ответить с цитированием