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

Get help using Construct 2

Post » Sun Mar 23, 2014 10:29 pm

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!
B
4
Posts: 9
Reputation: 243

Post » Mon Mar 24, 2014 12:59 am

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.
B
98
S
32
G
16
Posts: 1,204
Reputation: 16,715

Post » Mon Mar 24, 2014 7:47 am

That makes sense. Thanks a lot for the tip. Will give that a try tonight when I'm back from work.
B
4
Posts: 9
Reputation: 243

Post » Mon Mar 24, 2014 11:08 pm

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!
B
4
Posts: 9
Reputation: 243

Post » Mon Mar 24, 2014 11:28 pm

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.
ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494

Post » Tue Mar 25, 2014 1:51 am

@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..
B
98
S
32
G
16
Posts: 1,204
Reputation: 16,715

Post » Tue Mar 25, 2014 6:45 pm

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. :)
B
4
Posts: 9
Reputation: 243


Return to How do I....?

Who is online

Users browsing this forum: FabianB, richcoz81 and 35 guests