Hello.
I’m attempting to create a semi-complex door animation to activate when my characters raycast hits it, then it opens, and either:
Whilst the animation is happening it destroys the door’s collider to prevent any possible glitches or replaying the animation when the raycast hits it
Or
Destory the door (it sinks into the floor, walls and roof) once the animation is over (so a timed function I guess)
Here’s what I have so far
var rayCastLength = 10;
function Update()
{
var hit : RaycastHit;
//check if character is colliding with door
if(Physics.Raycast(transform.position,transform.forward,hit,rayCastLength))
{
//with the character
if(hit.collider.gameObject.tag == "door")
{
//open the door
hit.collider.gameObject.animation.Play("Take 001");
//destroy the door's collider
Destroy(hit.collider.gameObject);
}
}
}
Thanks in advance for any and all replies