- Home /
Duplicate Question
Detecting whether a player is touching the ground
I've been looking around for ages to find a script that would allow me to have an animation and/or a sound played every time the player touches the floor. I looked at a few jump scripts but they didn't really help. If you have a script or can write a script that would function something like: if the player touches the ground once: play animation. If the magnitude is great enough then play a sound.
Exactly what Fattie said. You need to search : http://www.lmgtfy.com/?q=unity+player+touch+floor
There are other considerations. Are you using a character controller? Then lok into the isGrounded variable. Are you using a rigidbody? Then look into OnCollisionEnter
http://docs.unity3d.com/Documentation/ScriptReference/CharacterController.html
http://docs.unity3d.com/Documentation/ScriptReference/CharacterController-isGrounded.html
http://docs.unity3d.com/Documentation/ScriptReference/Collider.html
http://docs.unity3d.com/Documentation/ScriptReference/Collider.OnCollisionEnter.html
Answer by Fattie · Apr 07, 2013 at 08:07 PM
You just raycast to do this. IT's how all video games work. SEARCH on here for 100s of answers about it.
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
hide child object script - help 1 Answer
Disable a script on collision 2 Answers
How to see object through collision? 0 Answers
Very simple picking up items script? 2 Answers