Hi, i try to find the answers on unity and youtube but i cant find why my script wont work. I dont get an error but my script just do nothing.I want my player(first person) to open door when he look at it. I put the script on the camera.The debug.ray show exactly the ray i want. Here the script:
function Update ()
{
var Hit:RaycastHit;
if(Input.GetKeyDown(KeyCode.T) && Physics.Raycast
(transform.position,transform.forward,Hit,5))
{
if(Hit.collider.gameObject.tag=="porte")
{
Debug.Log("La porte Ouvre");
}
}
Debug.DrawRay(transform.position,transform.forward*5,Color.green);
}
I dont know why i wont work i check the tag i use a built-in one like Player
nothing seems to work if someone could explain me why it will be great cause it will be usefull to me to understand raycast.