How do I interrupt an in progress event?

0 favourites
  • 11 posts
From the Asset Store
Progress\Loading Bar. Now Load you game like a Professional.
  • So basically I have an enemy with the platform behavior that will move back and forth between waypoint sprites. When he reaches a waypoint he then PICKS another waypoint at random and then moves towards it, rinse and repeat.

    I am trying to get him to stop while he's on his way to a waypoint.

    I can stop him once he gets there but if he's already picked the waypoint I can't. I've tried disabling the waypoint group itself, I've tried inserting variables here and there. Nothing seems to work. I can stop him temporarily by disabling his platform behavior, but once I start it back up he just picks up where he left off lol.

    It seems like once he's picked the waypoint and the event is running there's no stopping it. I thought about destroying the waypoint he picked, that might work right? But unfortunately for other reasons in the game destroying the waypoint isn't an option.

    Any ideas on this one? I feel like I'm missing something fairly simple here.

  • What kind is a "waypoint" in your project? And how is the movement handled?

    If you can, please provide a capx.

  • Sure. I can't post the game but here's a quick mock-up.

    https://dl.dropboxusercontent.com/u/349 ... point.capx

    It uses a custom behavior by RexRainbow however so you'll need that to open it.

    https://dl.dropboxusercontent.com/u/577 ... oveto.html

  • Tried the behavior, but I can't figure out your problem.

    You need to set the new waypoint to the actual position of the AI when you deactivate the behavior.

    Here's the test, the orange sprite is dragabble and the target. Every 1 second the PlatformMoveTo behavior is switched on/off.

    [attachment=0:2n8v5ymf][/attachment:2n8v5ymf]

  • Thanks, I see what you're doing there but that's exactly the issue I'm having. As soon as you turn his platform behavior back on he'll pick up right where he left off and continue moving.

    I can stop him while he's walking no problem, but I'm looking more for a way to stop the entire movement loop completely while he's walking. Because I want his platform behavior available for other actions.

    In the actual game I have for each events on the enemies because there's more than one of them. You would think the stop loop action would work... but it doesn't seem to.

    Thanks for helping though, much appreciated.

  • Did you try the Controls in my capx? You can use it while the waypoing stays the target already.

    The difference is to use the object as the waypoint target, instead of waypoint.x . Once stopped, move a temporary waypoint to the Players position, and set it as new waypoint. So the old target is overwritten.

    All right? Here is a simple solution without using rex's behavior, but simulated Keydowns.

    [attachment=0:39fvgcdm][/attachment:39fvgcdm]

    Hope it helps.

  • Thanks, I'll have a look at it. I appreciate the help!

    Seems very odd to me C2 doesn't have a way to break a loop though.

  • It has, but this addon does not support it.

  • You're right, it was the addons fault.

    On a whim I was playing with while loops. Without the behavior they stop, with it they don't. How strange.

    Anyway you were a huge help. Thanks so much for taking the time to help me

  • No problem, I appreciate finding solutions for every new c2 version (and its possibilities).

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can try adding a "Stop" boolean variable to your enemy object, and have this check in a base level event

    Enemy moveTo is moving

    Enemy is Stop

    and use the moveTo Stop action to make it stop moving and then do whatever you wish

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