Forum rules - please read before posting.

Object Animation in 2D game

Hi.
I went through the "Adventure Creator: Creating a 2D game tutorial" and wanted to try something by myself. when I animated my player everything went well like we were instructed in the tutorial, but when i tried animating objects I had the options: animation method, engine, object and clip.
I tried using custom but i had no place to enter the animation name. I tried entering an animator controller but it also didn't work.

My question is: how did you make the worm move in the game, or any game object? do i still use the "old way" of animator parameters? is there an easy way that i missed?

thanks.
Avinoam


Comments

  • Welcome to the community, @aviavi16.

    To animate non-characters, you'll want to make use of the Object: Animate Action.  Your choice for the Animation engine field will depend on the way in which you want to play your animations.

    For 2D objects, this is best set to either Sprites Unity or Sprites Unity Complex.  "Sprites Unity" allows you to type the clip name you wish to play - but bear in mind that this clip must already be present in the sprite's Animator Controller, on the layer that you specify in the Mecanim layer field.

    "Sprites Unity Complex" allows for this as well (via the Play Custom method), but also for playback through the changing of Animator parameters (via the Change Paramater Value method).  Which you choose is down to you, but it's generally considered better practice (so far as Unity goes) to control animations via parameters.

    The worm in the 2D Demo is animating continually, so there's no need to control its playback during the game - its default animation is set to "WormIdle" and it's left as-is.

    A better example for 2D object animation playback is the tyre-swing, which plays an animation when the player "uses" the "Tyre swing" Hotspot.  The TyreSwing object has an Animator Controller with two animation states: TyreIdle (the default) and TyreSwing).  No parameters are used, but there's a transition from TyreSwing to TyreIdle upon completion.

    To play the TyreSwing animation, the Sprites Unity engine is used to play the clip by name reference.  See the "Tyre_Use" interaction object's Object: Animate Action, which is the second in the ActionList.

    If you'd like some specific help with getting your animation to play back, please post screenshots so that we can see what you've got so far.
  • edited May 2022

    Hi, not sure if this will be bumped somehow, but I wanted to avoid creating a new thread for this.
    I also have an animated object similar to the tyre in the demo. Everything seems to work fine, except for the fact that apparently, the option "wait until finish" in the action list seems to always be ignored. The action list keeps being played in parallel to the animation. I tried both sprite unity and sprite unity complex as engines. Maybe I'm missing something?

    For reference, "wait until finish" on character animations works fine

    It's not a big obstacle but having to add a "wait" command after each animation is a bit annoying, especially since the animations lengths need to be adjusted from time to time.

    I'm with Unity 2021.2.14 and AC 1.75.0

  • Rely on Sprites Unity, and then in a backup/duplicate project, update to the latest release - issues related to this topic were recently addressed.

    If the issue remains, share screenshots of the Animator and Action and I'll attempt a recreation.

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.