Hey i wanna make a script that makes a animation start when i press a button… im using
function Update () {
if (Input.GetKeyDown (“space”))
animation.play (“space”);
}
But thwn i press space the game goes back to edit mode, but stil the game is running acording to the play and pause button. becuse they are highlighted…
Why is this happening?
Also it works perfect if i make a
transform.rotate script instead of the animation.Play…
But no one on the internet seems to show how to animate with codes.
What do you mean that it goes back to Edit mode? If the play and pause button are both hilighted then it is paused, not returned to the edit mode. If you have “Error Pause” enabled (in the console window) chances are that you’ve hit an error somewhere and paused as a result. And my guess is that the error is that you’re not calling the animation correctly, or the animation is not set up in the Animation component on the object.
Aside from having incorrect capitalization, the code example you have there is roughly how I’d do it, and it’s always worked form e.
Also hoping that you’re actually doing animation.__P__lay(“space”) as well (and that “space” is the name of a clip already attached to the animation component one way or another)
Well i just make the animation and save it, and then ill get the animation and something else in my assets folder, after that i make a javascript and add the code. then i drag the script to r
the object and thats it. what else do i have to do?