Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

i have made a simple animation for moving the game camera from one site to another, for the purposes of showing a menu, and then, going to the zone of the game itself. I do this using the animation window of unity. When i run the game, the animation plays and the camera moves, so i suppose that is correctly associated with the camera. The thing is that i want to control the animation from an script, so I can make it run when i want to, not at the begining of the game. The question is: how can i access the animation of the camera from an script? I tryed gameobject.animation.stop("animation") but i get this error: "MissingComponentException: There is no 'Animation' attached to the "Camera" game object" Thanks.

Edit-------------------

i'm adding the objects hierarchy of the project. hope it helps. enter image description here

share|improve this question
    
Yes there's a way to control the animation from scripts, but we'd have to see your object hierarchy to see exactly where the animation component lives. –  Tetrad Apr 6 at 6:47
    
You'd also want to turn off the "animation on start" option on the animation component. –  Tetrad Apr 6 at 6:47
    
object hierarchy added. Thanks. –  pablopp83 Apr 6 at 16:44
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.