Skip to content

Instantly share code, notes, and snippets.

@markusrt
Created July 24, 2012 19:51
Show Gist options
  • Save markusrt/3172215 to your computer and use it in GitHub Desktop.
Save markusrt/3172215 to your computer and use it in GitHub Desktop.
Unity: Check if player stopped falling and position on ground
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