Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. bool isgrounded = true;
  2.  
  3. void Update()
  4. {
  5. if (isgrounded == true)
  6. {
  7. //Do your action Here...
  8. }
  9. }
  10.  
  11. //make sure u replace "floor" with your gameobject name.on which player is standing
  12. void OnCollisionEnter(Collision theCollision)
  13. {
  14. if (theCollision.gameObject.name == "floor")
  15. {
  16. isgrounded = true;
  17. }
  18. }
  19.  
  20. //consider when character is jumping .. it will exit collision.
  21. void OnCollisionExit(Collision theCollision)
  22. {
  23. if (theCollision.gameObject.name == "floor")
  24. {
  25. isgrounded = false;
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement