Hi UniGuys, here im trying to make better my character controller and here is my problem and question.
After Jump when my character in falling and want to change the animation when the character touch the ground, and after this animation change to the idle animation.
how i can detect that im in the ground and play the (AnimTouchGround) and when it finish start the the Idle animation?
thanks
Do a Raycast from the CharakterFeetPoint in the negative Vector3.up direction if you hit something with the raycast you have found the ground.
Could be improved but its a start.
Easiest way is to do a collision check on the terrain and when the player collides with he terrain, play the animation.
Another, more complex solution is to first have a boolean variable defaulting to false that determins if the player is in air. Once hte player jumps, set the boolean to true and do a Raycast to the ground to find it’s position. Once you know that, you could use the bounds variable of the player’s collider component to find the bottom of hte collider, then compare the lower bounds to the y value of the RayCastHit object returned by the raycast. if they are the same and the boolean value is currently set to true (denoting the player is mid-jump), you play the animation and reset the boolean value to false.
The latter approach requires that either (a) the terrain is flat) or (b) the player can only jump strait up and falls strait down… otherwise it will not work correctly.
The first method is the best approach.