Hi, I'm making a sidescroller controller and cant get pass the jumping. I need to know when the player is on ground.
I know I can raycast but it's not working right with just one raycast, and I can't figure out working with multiple rays.
After a bit of googling and searching I got this far.
function OnCollisionStay(coll : Collision)
{
if(coll.contacts.Length > 0)
{
var contact = coll.contacts[0];
if(Vector3.Dot(contact.normal, Vector3.up) > 0.5)
{
onGround = true;
}
}
}
But as it works when on ground, I don't know how to check when its off ground. I tried a bunch different else if's but none worked.
Any suggestions? Or a better way for doing jumping?
Thank you!
↧