What I’m, trying to do:
When my player is looking at the doors, he can left click and make the door’s script play the animation to open / close.
My player camera’s script:
var Door : Door_anim;
function FixedUpdate()
{
var hit : RaycastHit;
var ray: Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
//if(Physics.Raycast(ray, dist))
//{
//print("Found an object - distance: " + hit.distance);
//}
if(Physics.Raycast(ray, dist) && hit.collider.tag == "Doors" && Input.GetMouseButton(0))
{
Door = hit.collider.gameObject.GetComponent("Door_anim");
Door.animate();
}
}
The door’s script
```javascript
**#pragma strict
var triggered = false;
var closed = true;
function animate()
{
if(closed)
{
GetComponent.().Play(“Door_open”);
closed = false;
}
if(!closed)
{
GetComponent.().Play(“Door_close”);
closed = true;
}
}**
```
The door
The error i get when looking at ANY object with a hitbox
Thanks in advance master scripters