Problem implementing code idea regarding sine action

0 favourites
  • 4 posts
From the Asset Store
Two levels with two sistem Wave. with Source-code (.c3p) + HTML5 Exported.
  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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

  • 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.

  • 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.

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