Quantcast
Channel: Answers for "Checking if object is in air or on ground?"
Viewing all articles
Browse latest Browse all 8

Answer by FLASHDENMARK

$
0
0

I use this:

var jumpHeight = 7.5;
var canJump = true;
var jumpCount = 0;

function Update () 
{

if(Input.GetButtonDown("Jump") && jumpCount == 0)
   {
   rigidbody.AddForce(Vector3.up * jumpHeight, ForceMode.Impulse);
   jumpCount = 1;
}
}

function OnCollisionEnter (hit : Collision)
{
if(hit.gameObject.tag == "Floor")
    {
    jumpCount = 0;
    }
}

If your ground is tagged "Floor" you should be able to jump no matter if it is a angular surface or not.


Viewing all articles
Browse latest Browse all 8

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>