Forum rules - please read before posting.

How to get an animation work only once?

edited March 2015 in Technical Q&A
Hi! My first question here,

I'm still figuring out in a testgame how things exactly work now. But one thing is really breaking my head. I'm working in 2D. I have made an NPC that doesnt move. (Cause i dont want it to move) But the player can have a small conversation with it now, that works, and it can use an inventory item on the npc, that also works except for one thing. In the action list of what happens when you use the item on the npc I also want to play an animation, only once. And then the npc changes in something else. That all happens, but I can't get the animation working. How do i do that?

In the meantime I had it working, the animation. But it was just playing all the time on the NPC and not only once at the moment that I wanted it to play. 

Comments

  • Welcome to the forum, @roelienvn.

    I'll need some more detail about your setup before I can help too much - screenshots of your Animation Controller and NPC inspector would be a big help.

    You need to use the "Character: Animate" Action to animate an NPC beyond the standard idle/walk/talk animations.  What have you got currently?
  • edited March 2015
    Hello Chris,

    I allready solved it, But I think it is in an unhandy way. I remove the object that I want to animate now and then add an object that plays the animation and then make that dissapear again. The object: animate or Character: animate actions I cant get them to work yet... So something is going wrong I guess? anyway in the screenshot:

    Kapoetski is an NPC, It doesnt move, you can talk to it and feed it a carrot, and then it explodes, so there we need the animation. Kaputski is the animation that does work so as you can see it replaces the not animated robot. and then that also disapears and the robot changes into a chicken. Great storyline heh? but step 1 2 and 3 can also run in one action with character animate I think? but how? 

    and ehm.... how can i add the screenshots?


  • Just upload an image to imgur.com or whatever you prefer and paste in the link.

    The Character: Animate Action is used extensively in the 3D Demo, which is included with AC.  I'd suggest picking it apart to see how it's made, when it comes to things like this.
  • edited March 2015
    ok I managed to get screenshots online :-) http://roelienvanneck.nl/fotos/temp/screenshot.png

    and the screenshots from the animation and controller, but I dont know what my setting were in the first place. Anyway, the animation till so far only plays all the time or not at all if I trie to use Character: animate or Object: animate. I tried both.

    I got the result I wanted with the actionscheme like you see in the first screenshot. But why not the easy way?

    I have never worked with animations or tried to make a game ever before, and I also don't know how to code, So I am a real noob if it comes to this.

    The NPC robot you see in the next to screenshots is the thing I cant get animated the way i want it.




  • I see - you shouldn't have both the Animation and Animator components on the same object, only one.

    While AC's Legacy (i.e. Animation component) is there to make things easy for those getting started (just call an animation, and it'll run), AC's Mecanim (Animator component) support is intended to give more control to the user over their animations - but it does require that the user is knowledgeable about the way Unity's animation system works.

    Have a look through Unity's documentation about Mecanim before trying to implement it in AC.  Otherwise, just make use of Legacy animation and let AC handle it for you.
  • Thank you, I don't think I shouldn't make it to difficult for myself, So I am just going to figure it out further in AC. I think maybe why it kept playing all the time was cause it was the only animation attached to it? Maybe it will help if I also have an animation called Idle_D on the character. Cause then it knows what to do when it is standing still. 

  • Yes, you definitely need an idle animation to play once it's finished!  Even one frame should do it.
  • edited March 2015
    I finally got that working the way it should work, (I think) But I did it with an animator component, not the animation component I really can't get anything to animate with  that component and the Legacy stuff. So I don't believe you if you say that is easier :-) But I'm going to struggle with it some more another time then.

    But in the screenshot you see how it works now, I think that might be the right way? It is a screenshot during testplay. I used the carrot on the robot and then it indeed plays the animation that I want and disapears. (as it should do)  And the actionlist is a lot shorter then it was when I got it working last week. So that is good! 

    Slowly I'm starting to understand how things work. And my trials are starting to look like a game. Never thought I would ever be able to make something like that myself. It is gonna take me years I guess but there will be a game some day :-) Thanks for making these awesome tools!

    image
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.