How to perform an action once when sprite reaches a position

0 favourites
  • 3 posts
From the Asset Store
Change the size and position of everything without calculating anything!
  • Back again!

    I have a Sprite with the Platform behaviour. I am then simulating controls to make the player move automatically on load to the right.

    When the player reaches a certain position I want to increase the movement speed and send the player back in the other direction.

    To increase the speed I have the following event:

    PlayerSprite | X <= 500 | Add 10 to MovementSpeed and then Set Platform maximum speed to MovementSpeed

    It also then switches the direction from right to left, and I have another condition for when the player reaches the left side of the layout to again add more speed and send it back to the right.

    It works fine - but it is adding multiple amounts of 10 - so it is firing more than once when it changes direction. I am at a loss to why this is happening. Not sure if it is because the player seems to have inertia so spends more than one tick at an X position of 500 or greater.

    I tried having the condition being X is equal to 500, but it never fired because looking at the debug profiler it is never 500 exactly, it will be like 500.9875223355346567.

    How can I make it fire the once?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Try the System:Once on true condition. However it will still not be exactly equal to 500.000000. You could have a range check 499.99 <= X <= 500.01 instead.

  • Thanks, this additional condition on my existing condition for the sprite worked without any alteration!

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