|
Hi, i need help with a health bar which only takes damage if you were to fall from a certain height or higher. I am not asking anyone to write my code as i want to learn how to script myself, much like my other question "Wall Jump Help" could anyone tell me what sort of things i would need to write for this to work, thankyou.
(comments are locked)
|
|
Use this to understand if the collision was from below: http://unity3d.com/support/documentation/ScriptReference/CharacterController-collisionFlags.html And use this to understand the velocity of the collision: http://unity3d.com/support/documentation/ScriptReference/Collision-relativeVelocity.html So use an OnCollisionEnter method and inside it, check if the character is collided from below, if it is do your damage calculations.
(comments are locked)
|
|
You would need to keep track of the change in the objects y position between frames i.e. current and previous. Then if the change is minus, going down, then store a start position based on the previous and flag that object as falling. Now that you have the object as falling you can check for there being no difference between the current position and the previous. When there is no difference you have stopped falling and you can calculate the distance that the object has fell from the start position and base the damage from that.
(comments are locked)
|
