Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool isgrounded = true;
- void Update()
- {
- if (isgrounded == true)
- {
- //Do your action Here...
- }
- }
- //make sure u replace "floor" with your gameobject name.on which player is standing
- void OnCollisionEnter(Collision theCollision)
- {
- if (theCollision.gameObject.name == "floor")
- {
- isgrounded = true;
- }
- }
- //consider when character is jumping .. it will exit collision.
- void OnCollisionExit(Collision theCollision)
- {
- if (theCollision.gameObject.name == "floor")
- {
- isgrounded = false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement