fall Demage
this code doesn´t function becouse debag log write wrong fall distance... please help me
public class FallDemage : MonoBehaviour {
float y;
float Y;
float Demage;
bool ground;
bool activ;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
CharacterController controller = GetComponent<CharacterController>();
ground = controller.isGrounded;
demage();
}
void demage()
{
CharacterController controller = GetComponent<CharacterController>();
if (ground == true)
{
y = transform.position.y;
}
else
{
activ = true;
}
if (activ == true && controller.isGrounded == true)
{
activ = false;
Y = transform.position.y;
}
Demage = y - Y;
Debug.Log(Demage);
if (Demage > 0)
{
Debug.Log(Demage);
Demage = 0;
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Carried object through terrain 0 Answers
How to know where my object is going to fall? 1 Answer
How can i get a object fall and go up random? 0 Answers
Fall Damage script not working 1 Answer
Disable input while falling? 2 Answers