How do I get my enemy to move once, then go idle, then move again? In a more methodical patrol

0 favourites
  • 9 posts
From the Asset Store
The ultimate voice pack filled with 1,536 files of .......wav and mp3 of individual numbers, letters, and words (that go
  • Sorry for the long title, I'm confused how to phrase my problem briefly. I drew an enemy (a toad), and he has an idle animation, and a hop. I want him to cycle the idle animation ONCE, then hop to the left ONCE, and repeat ad infinitum until he hits my collision wall to reverse (mirror) his animation, or the player stomps him. I cannot figure out how to set up the event sheet for this.

    I'm new to this, so please keep that in mind when typing answers - I may not know lingo or acronyms.

    Thank you

  • Because what you're describing is animation based, at a basic level you can make use of 'on animation finished', so 'on Idle animation finished' set animation to hop. 'on hop animation finished' set animation to idle, to flick between them.

    The problem here is when you say hop to the left it sounds like movement and with that logic he won't move so it's up to you how much he moves. What does hop once mean in context of your platformer ? He moves a little bit and plays hop ?

    If he moves only when the hop anim plays one time then you could still make use of animation events, so 'is hop animation playing' then simulate control on the frog.

  • Thank you for replying!

    The context (I believe):

    When the screen starts, I want the toad's idle animation to play once, then he "moves left" (hop animation) for 16 pixels (or some very short distance), and then the hop animation stops, and the idle animation begins again, for one cycle, and I want this to continue until the toad bumps into my collision wall and turns around (mirror) and repeats the action in the opposite direction.

    I set up the enemy with the platform behavior, and when I do the tutorial's "Every Tick" function, the toad just glides across the platform, and I would like to make him hop, then pause, do his idle animation, then hop again.

  • Sure then try the above. Every tick isn't going to work nor is it needed here. You can run events based on animations finishing. There is also a Timer behaviour option but I think anim events could work for now, try it.

  • OMG it worked! THANK YOU! I looked up the "on animation" conditions you mentioned and set them up in the pic below.

    I turned off "looping" for the animations

    set the "idle" animation to play "on created", then when that finishes, I set the "move" animation to play, and looped it. The tricky part was setting up the movement, but I found the proper syntax, and now my toad hops! THANK YOU for your help and patience!

    Uploaded pic for future reference

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • However... I have another issue if you would like to continue this thread.

    I got the toad to move in the direction I wanted, and he "hops" - it is all perfect. However, I cannot get him to "mirror" his direction and proceed with his movements in the opposite direction.

    My context:

    set a Boolean (direction_left) with an initial value of true. Then I created a sprite to use as an invisible collision wall (collision_enemy_left).

    When the toad touches ("on collision with") the invisible wall, I "toggle" the Boolean to false

    Then, I repeat the same events as previous, only with the condition that "direction_left" is false (I inverted the event). Since the condition is false, I just reversed the enemy's movement (toad.X+.05).

    The enemy's animation cycle works, all the way up to him touching the wall. When he collides with the wall, the idle animation begins, but he just sits there, cycling the idle animation, and the sub events are not initializing.

    Would you have any idea what I am doing wrong?

  • The top event you added runs constantly and overrules a lot of the events, as a habit you shouldn't really put trigger events (green arrow) as sub events. To fix this, delete the 2 duplicated events you won't need them, and bring the 'is animation playing' up to the main level not a sub event. Then for the two 'is animation playing' events you add the condition directly to each one if direction_left is true, and one where direction_left is false.

  • I DID IT!!!! I'm not sure if I did it correctly (or the exact way you instructed me), but I found a way, it's less messy than before, and ultimately, IT WORKS - the toad moves incrementally and changes directions based on contact with a sprite.

    You mentioned adding another condition, and I looked up adding additional conditions - so I added a collision event, and "set mirror", then I just added the value check "is mirrored" to the enemy animation. I am sure I have no clue what I just typed, but I included a picture.

    Thank you for all your help!

  • Yeah that works. You removed the is playing check and instead added it in the same event with a wait so that's another way of doing it. They key thing is each event is a trigger once type event!

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