unity fall damage c#
using UnityEngine;
public class Collisions : MonoBehaviour
{
[Tooltip("In Meters")]public float distanceAllowedToFall;
float jumpHeight;
float landingHeight;
float fallDistance;
private void OnCollisionExit(Collision collision)
{
jumpHeight = transform.position.y;
}
private void OnCollisionEnter(Collision collision)
{
landingHeight = transform.position.y;
HealthDrain();
}
void HealthDrain()
{
fallDistance = jumpHeight - landingHeight;
if (fallDistance > distanceAllowedToFall)
{
// Damage Player
}
}
}
Also in C#:
- c# object clone
- asp.net c# write string to text file
- send type as argument c#
- null coalesce ternary c#
- uinput dialog uwp c#
- ASP select box all states
- internal c#
- c# string methods
- how to reference scripts in other scenes unity
- math class C# exponents
- Unity if object doens't exist
- how to create a list c#
- unity access child
- how to raycast unit
- asp.net textarea disable resize
- console.writeline c#
- datatable return column names
- unity cycle children
- c# try catch error
- unity 2d horizontal movement help
- .net core cli
- get attribute value of xml element c#
- c# console delay
- how to move clipping planes C# in unity