Animation trouble

This forum is currently in read-only mode.
From the Asset Store
4 Block Soldiers with different animations, 400x400
  • I've got my 'walking' animations all sorted and groovy and I've set it so that when the sprite isn't moving it changes to the appropriate stationary position that it's facing but I've come across trouble with using any other animation. What I want is for my ninja to animate a seperate animation when pressing X, but because of the whole default stationary programming, it's not playing. Can anyone help me find a way around this problem? Here's a screenshot of the events. F.Y.I. that's the only programming in the game thus far.

    http://i3.photobucket.com/albums/y78/Omen6/problem.jpg

  • Your "On key X Pressed" event only triggers one time when you press the key. Then the event sheet starts over again, and you're setting your animation to something else in the very next tick.

    You need to, um... not do that. Sorry, I'm getting very lazy with my Help replies lately.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Can anyone elaborate on that? I understand it but don't know how to bypass it. I had an idea of triggering a timer on pressing X as well and then having a sort of 'while the timer's going, play keep the animation going' type event, but as far as I know, that's not any sort of in-construct event command xD

  • I have a feeling that the Else statement is screwing you up. Let's see what happens:

    • checks if walking, plays the walking animation
    • then if the above fails, it plays standing animation
    • now check for key pressed, in this case it starts another animation

    After one tick, it checks those events again, but the "key pressed" already triggered in previous trick, so it won't trigger in this one. Meanwhile, the above two events had triggered already, resetting the animation to either one. So, your X animation only plays for one tick.

    I suggest replacing the Else event with this (right click the condition to invert it):

    + is NOT walking

    + X-animation is NOT playing

    play idle animation

    Also, you might want to add the "X-animation is NOT playing" condition in walking animation event, too.

  • Yeah, what Mipey said.

    *dusts off hands* Welp, my job is done here.

  • Your job should be done, but it isn't xD In theory this should work...but it doesn't :/ This is my new code.

    http://i3.photobucket.com/albums/y78/Omen6/problem2.jpg

    Once more, it begins, but then hangs after the first frame.

  • Try this for event 4:

    NOT Player: Animation "Animation 2" Is playing

    NOT Player: Animation "Animation 1" is playing

    Player is walking

    action: Set animation to "Animation 1"

    Because, this:

    NOT Player: Animation "Animation 2" Is playing

    Player is walking

    action: Set animation to "Animation 1"

    is going to constantly set the animation to Animation 1, starting from its first frame, no matter whether Animation 1 is playing already or not.

    Basically, you want to check that the animation you intend to play is not playing already.

    At least that's how I understand it, and that is how I am doing it.

    Likewise for your next event, you will probably want:

    NOT Player: Animation "Animation 2" is playing

    NOT Player: Animation "Default" is playing

    NOT Player is walking

    action: Set animation to "Default"

    I think that might be what Mipey meant.

    You may want to do similarly for event 6, On key X pressed, depending on what your animation does.

  • I'm afraid it still doesn't work :/ It now continually plays the walking animation and plays the X animation and then sticks.

  • try a state machine with a private var defining current state and animate according to that state

  • Yep, finite state machine. Give the ninja a private variable 'state', then set it to whatever the ninja is doing - "walking", "standing", "pickingnose"

    Then you just compare that variable and play an set an according animation.

    Finite state machines make game development much easier.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)