Hi, i wrote this code :
void OnCollisionEnter (Collision col)
{
if (col.gameObject.name == "Background")
anim.SetBool ("IsFlying", false);
}
I need to pass as parameter something that identify the terrain collision.
But i don’t know how use the function OnCollisionEnter… Can someone give me some examples ?
Thank you so much
I tryed to put it in my code, but nothing has happened...
– aled96void Update(){ RaycastHit hit; Ray ray = new Ray(transform.position, Vector3.down); if(Physics.Raycast(ray, out hit)){ print(hit.collider.name); } } see what it prints. If ti prints "Player", you need to set the player to ignore raycast. Layer-> Ignore raycast. But for some reasons, it seems that lately inner raycast ignores the collider it is starting from inside...
– fafaseIn the console: Tag: Background is not defined! prova.Update() But Background is not on my character: There are Camere, Background and Character
– aled96CompareTag uses the tag of the object not the name. Background is probably a name while it should be a tag. Just add it as a tag and assign it to the object.
– fafasei have a character that can fly, but i'm trying to "lock" (false) the fly if he is touching the ground.. but now everytime i fly the fly mode is put into false...
– aled96