Created
July 24, 2012 19:51
-
-
Save markusrt/3172215 to your computer and use it in GitHub Desktop.
Unity: Check if player stopped falling and position on ground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ( Physics.Raycast( | |
new Vector3( | |
thisTransform.position.x-0.3f, | |
thisTransform.position.y, | |
thisTransform.position.z+1f), | |
-Vector3.up, out hit, 0.7f, groundMask) || | |
Physics.Raycast( | |
new Vector3( | |
thisTransform.position.x+0.3f, | |
thisTransform.position.y, | |
thisTransform.position.z+1f), | |
-Vector3.up, out hit, 0.7f, groundMask) ) | |
{ | |
falling = false; | |
thisTransform.position = new Vector3( | |
thisTransform.position.x, hit.point.y + xa.playerHitboxY, 0f); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment