Hello.
In an FPS game, I am trying to get a box to play an open animation whenever the player collides with it.
The box has ana animation that opens its lid (the lid is a child of the box). Whenever a copy of the asset is created, its animation will play automatically whenever the game loads, as expected.
I have the following script attached to the First Person controller:
function OnControllerColliderHit(hit : ControllerColliderHit)
{
if(hit.gameObject.tag == "chest")
{
hit.GameObject.animation.Play("box_open");
}
}
Next, I add a Box Collider to the box object (parent, not the lid) and disable “Play Automatically” in its Animation component. I then add a “chest” tag to it for the script.
When the player walks into the object, no animation is played and the game actually chugs while the player is in contact with the box.
I am definitely missing something here, just not quite sure what it is. Any assistance would be greatly appreciated.
Gah! That was totally it! I didn't notice that typo. Thank you much for your help. :)
– JoshC