- Home /
Question by
Wololo Plays · Jun 22, 2014 at 01:44 AM ·
gamegameplayfalllife
Life calculator
Hello, I have 2 script and a is I control a life bar. And the other is to calculate the fall.But I would not prescisase click to lower the bar,I would like to do this fall calculator do this for me.
Note: I'm Brazilian and my Unity is free And I'm kinda stupid in these parts so please let the script ready
#pragma strict
var Person : CharacterController;
var Velocidade : float;
var Pisando : boolean;
var Life : int;
var Dano : int = 2;
function Start () {
}
function Update () {
Person = GameObject.FindObjectOfType(CharacterController);
Velocidade = Person.velocity.magnitude;
}
function OnControllerColliderHit(Co : ControllerColliderHit){
if(Person.isGrounded){
Pisando = true;
}else{
Pisando = false;
}
if(Velocidade >= 14){
if(Pisando){
Life -=Velocidade * Dano;
}
}
}
-------------2º
#pragma strict
var texButton : GUISkin;
var posY: float;
var Alt: float;
var Lar: float;
var QntVida:float;
var MaxQntVida: float;
var tempo: float;
function Start () {
QntVida=100;
MaxQntVida=100;
}
function Update () {
Lar = Screen.width/4 * (QntVida/MaxQntVida);
posX = Screen.width/2 - Lar/2;
posY = Screen.height/2 - Screen.height/4;
Alt = Screen.height/10;
if (Input.GetKey("c"))
{
if (QntVida>0)
{
QntVida = QntVida-0.5;
tempo = -60;
}
}
if (tempo>=0)
{
if (QntVida<100)
{
if (tempo>0.01)
{
QntVida = QntVida+0.5;
tempo = 0;
}
}
}
tempo=tempo+Time.deltaTime;
}
function OnGUI()
{
GUI.skin = texButton;
GUI.Button(Rect(posX,posY,Lar,Alt)," ");
}
Comment
Your answer
Follow this Question
Related Questions
Life Bar controlled 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Click Submit, then check 0 Answers
How i can add a life for the user if he buy it? 0 Answers
Infinite 2D placement grid 1 Answer