How do I setup a timed "stuck to the wall" mechanic

0 favourites
  • 7 posts
  • Hey guys, a little help if you don't mind. Just started getting into Construct 2 so am a little fresh to it all.

    So I'm busy setting up a game mechanic for when the player is against either the left or right wall they stick for x amount of time or until they choose to jump away. I'll be brief, but currently I have it setup for example when the player is not on the floor and has wall the right. Platform is disabled and wait is set to 3 seconds after which they fall to the floor. I then want it to run a left jump action away from the wall cancelling the 3 second wait if the player chooses so.

    As I said I've been very brief. I have tried a few different attempts with variables for an on/off playerStick and playerStickTime. It works apart from I always have to wait for the 'wait' action to finish before it proceeds to either the on/off playerStick.

    I'm probably (I hope) making this more complicated then it needs to be. Any advice on a simple way to go about this would be greatly appreciated.

    Thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Give your player sprite the Timer Behavior. You can restart or stop (cancel) the timer whenever you want. And there is a OnTimerFinished event that you can trigger so you know the timer finished without interruption.

  • That makes sense. Thanks a lot for the tip. Will give that a try tonight when I'm back from work.

  • Ok so I've given the Timer behavior a go and I see it's not working how I had expected initially. So for example I have it set so when the player is not on the ground and wall is to the right > Start Timer. I thought this would trigger my On Timer event running the next set of actions for disabling the platform, making it appear the player is stuck to the wall before the event time runs it's course or the player decides to jump away (running an action to Stop Timer). I now realise the Start Timer actually begins when the player jumps up to the wall but then falling back to the ground. My plan of course was to get him to stick first.

    I guess I've got this all wrong. Could you please explain a little further?

    Thanks again!

  • The OnTimer runs at the end of the time period, not the beginning. You would stick your player at the same time you start the timer. You unstick when OnTimer is called.

  • rheece

    also you want to use a one-off timer.. or Type=Once... the <Duration> is the time until OnTimer triggers... and that will fire once and not again until StartTimer is called again..

  • Edit...

    Ok so I've edited this reply since so far I have found the solution and got over the whole On Timer stick to the wall hurdle. Ended up using a compare variable in conjunction with Start Timer. So far it works. But now some new challenges of course. Thanks for the help though guys. Timer behaviour definitely solved the biggest headache.

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