Code : Tout sélectionner
if (Physics.Raycast(ray, out hit, Camera.main.farClipPlane))
{
Debug.Log("N°4 Dans le if(Raycast)");
if (hit.transform.gameObject.tag == "Ennemi")
{
Debug.Log("N°5 Collision avec un ennemi ");
hit.rigidbody.AddForceAtPosition(transform.TransformDirection(-Vector3.forward) * 1000, hit.normal);
}
if (hit.transform.gameObject.tag == "Mur")
{
Debug.Log("N°6 Collision avec un mur ");
GameObject Go = Instantiate(Impact, hit.point, Quaternion.FromToRotation(Vector3.forward, hit.normal)) as GameObject;
Destroy(Go, 10F);
}
}
}
Code : Tout sélectionner
if (Physics.Raycast(ray, out hit, Camera.main.farClipPlane))
{
Debug.Log("N°4 Dans le if(Raycast)");
Debug.Log("N°4 - BIS hit.transform.gameObject.tag = "+hit.transform.gameObject.tag);
if (hit.transform.gameObject.tag == "Ennemi")
{
Debug.Log("N°5 Collision avec un ennemi ");
hit.rigidbody.AddForceAtPosition(transform.TransformDirection(-Vector3.forward) * 1000, hit.normal);
}
if (hit.transform.gameObject.tag == "Mur")
{
Debug.Log("N°6 Collision avec un mur ");
GameObject Go = Instantiate(Impact, hit.point, Quaternion.FromToRotation(Vector3.forward, hit.normal)) as GameObject;
Destroy(Go, 10F);
}
}
}