Do an action every tick for X seconds?

Get help using Construct 2

Post » Wed Feb 13, 2013 11:20 am

This is probably plain as day, but I am missing it.

I want my PC to walk away from the wrong direction, so I start ignoring input and every tick simulate pressing left.

How do I do this action for only 1 second?

So "every tick" simulate control left "for x Seconds".

If someone could point me in the right direction I would be greatful. But please don't tell me exactly how to do it, I learn better that way, just need a steer in the right direction.
B
9
S
3
Posts: 148
Reputation: 1,738

Post » Wed Feb 13, 2013 11:26 am

The problem is right there in your logic: you can't do something for 1 second every tick. Every tick is usually every 1/60th of a second.

If you want to do something for X seconds, you need to have a more specific condition, like "on keypress", "on key released" or "on collision"
B
56
S
15
G
10
Posts: 910
Reputation: 11,942

Post » Wed Feb 13, 2013 11:39 am

[QUOTE=Awakening] This is probably plain as day, but I am missing it.

I want my PC to walk away from the wrong direction, so I start ignoring input and every tick simulate pressing left.

How do I do this action for only 1 second?

So "every tick" simulate control left "for x Seconds".

If someone could point me in the right direction I would be greatful. But please don't tell me exactly how to do it, I learn better that way, just need a steer in the right direction.[/QUOTE]

This could work:

Variable DisableControls = 1

Every 1 seconds
..DisableControls > 0
... Subtract 1 from DisableControls
... Set controls disabled

..Else
...Set controls enabled

Then you'd have another event where you define your walk left action.

.. your event
// walk scene starts
.. DisableControls = 1
.. //trigger your walk action
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Wed Feb 13, 2013 12:51 pm

B
44
S
15
G
9
Posts: 1,096
Reputation: 11,013

Post » Wed Feb 13, 2013 2:29 pm

[QUOTE=GeometriX] The problem is right there in your logic: you can't do something for 1 second every tick. Every tick is usually every 1/60th of a second.

If you want to do something for X seconds, you need to have a more specific condition, like "on keypress", "on key released" or "on collision"[/QUOTE]

I think you misunderstand me. If I want to have an AI move left, it has to be "simulating left" every tick to move smoothly. But how do I then get the AI/or a PC whose control is taken away from the player to stop after going left for 3 seconds?

So to be plain, I want to make something simulate pressing down left for 3 seconds. How do I do this so it moves left for 3 seconds then stops?Awakening2013-02-13 14:30:35
B
9
S
3
Posts: 148
Reputation: 1,738

Post » Wed Feb 13, 2013 5:29 pm

B
54
S
28
G
18
Posts: 1,520
Reputation: 24,990

Post » Wed Feb 13, 2013 5:50 pm

So there isn't just an expression instead of "every x seconds" something like"

"for 3 seconds" do this action...
B
9
S
3
Posts: 148
Reputation: 1,738

Post » Wed Feb 13, 2013 6:00 pm

[QUOTE=Awakening] So there isn't just an expression instead of "every x seconds" something like"

"for 3 seconds" do this action...[/QUOTE]

Nope, you could do it like I suggested, with timer variable.
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Wed Feb 13, 2013 6:06 pm

[QUOTE=vee41] [QUOTE=Awakening] So there isn't just an expression instead of "every x seconds" something like"

"for 3 seconds" do this action...[/QUOTE]

Nope, you could do it like I suggested, with timer variable.[/QUOTE]

Yeah thanks! I might do that! Seemed pretty straight forward. I just assumed there was an expression or something hehe.

However in this case, I just put a "when collide with object stop moving" type dealie, because I wasn't running a fully featured group of AI events, but more of a scripted event.

Thanks though! I appreciate everyones input.

B
9
S
3
Posts: 148
Reputation: 1,738


Return to How do I....?

Who is online

Users browsing this forum: GUN, Yahoo [Bot] and 18 guests