Problem implementing code idea regarding sine action

Get help using Construct 2

Post » Sat Aug 29, 2015 1:57 am

Hi, I am having problems with sine behavior and object colliding. The object is not bouncing off an object upon collision but sliding down it because of the sine behavior.
I thought of an alternative but I'm having problems implementing it in code:

On collision with object A
......If not colliding with floor B
............disable sine
............wait 1 second
............enable sine
......Else
............disable sine
............do not enable sine after 1 second

Basically if the box with sine behavior collides with object A, in order to override the sine behavior I am turning it off for 1 second and then turning it back on.
But I'm having a problem, because when the object falls on the ground I want the sine behavior to stop, which works until the box hits object A then hits the floor straight after. This causes the sine to stop upon hitting object A, but then when it hits the floor it is already stopped, but after 1 second it turns on again.
I'm not sure how to cancel the action of turning it on after 1 second after it hits the floor.

Thanks for you help.
Cheers.
Brick by brick, stone by stone.
B
52
S
24
G
17
Posts: 273
Reputation: 12,663

Post » Sun Aug 30, 2015 2:01 am

Create a global variable like Can_Sine. Use 0 for false and 1 for true.

Create 2 conditions:

Can_Sine = 1 > Box > Sine Active

Can_Sine = 0 > Box > Sine InActive

Box > On Collision with Object A > disable sine etc...

Box > On Collision with Floor > Set Can_Sine = 0
Image
B
75
S
23
G
3
Posts: 673
Reputation: 9,273

Post » Sun Aug 30, 2015 7:54 pm

TheDom wrote:Create a global variable like Can_Sine. Use 0 for false and 1 for true.

Create 2 conditions:

Can_Sine = 1 > Box > Sine Active

Can_Sine = 0 > Box > Sine InActive

Box > On Collision with Object A > disable sine etc...

Box > On Collision with Floor > Set Can_Sine = 0


Thanks! Simple and elegant!
I ended up making sure that the objects arent colliding with object B, only the floor instead, but this will come in handy. Still getting used to the mechanics.
Brick by brick, stone by stone.
B
52
S
24
G
17
Posts: 273
Reputation: 12,663

Post » Mon Aug 31, 2015 1:45 am

No problem. That's a simple approach. You can also use instance variables in the actual object/sprite. Learning to use variables is an important way to solve lots of issues.
Image
B
75
S
23
G
3
Posts: 673
Reputation: 9,273


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 6 guests