- Home /
Collision problem with terrain
Hi, i have a character that can fly, but i want that if he touch, with his feet, the ground the fly-mode become "false". But this not happens. This is the part of the code, regarding flyght:
if (anim.GetBool ("IsFlying") == true) {
if(Physics.Raycast(ray, out hit))
{
if(hit.collider.CompareTag("Terrain")){
anim.SetBool("IsFlying",false);
p1.SetActive(false);
}
}
}
But if he touches the ground, he doesn't stop flying... Can someone help me ? thank you
Answer by Zentiu · Mar 16, 2014 at 04:15 PM
try putting your player on a layer called Ignore Raycast. see if that helps.
did you already create your ray? is the terrain tagged as terrain?
Yes, i created a tag called Terrain, the ray yes it is created:
ray = new Ray(this.transform.position, Vector3.down);
and the problem is that with this code the character stops flying everytime, also if he is in the air and not only if he is touching the ground...
Now i'm trying to do the same with a Cube, if my y axis are higher than the cube once, so if i am on the cube, the flymode become "false" but not just if he is touching it... What sould i do ?
Would you like a photo ? $$anonymous$$aybe you can understand better..:)
What is the script you use to get him to take off? that might help me figure out your problem.