0 Favourites

How do I reduce player's speed when overlaping an object ?

  • The problem is easy, but I can't find a simple way to solve it

    How can I reduce player's speed when is overlapping an object and regain it's original speed when is not overlapping that object ?

    These are my events:

    The problem is that the second event (player is not overlapping stairs) is executed at the very start and increases player's movement speed.

  • Is your player moving at a constant speed before it overlaps? If so, then just have a variable that is called max_speed and when not overlapping, set player speed to variable.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Why do not you simply indicates his speed to the value of original speed?

    If you are not on the ladder, his speed will always be one.

  • zenox98 vitorfgd

    Thanks... Since the player has different speeds, I will use a global variable to store and restore it ... However isn't there a better/cleaner method to do this ? The game will be for mobiles so I want to have my game as clean/optimised as possible

  • (player is not overlapping stairs) Is not a sub-event or a called function to be triggered when asked for, thats why it is starting on start of layout.

  • (player is not overlapping stairs) Is not a sub-event or a called function to be triggered when asked for, thats why it is starting on start of layout.

    Thanks, I figured and fixed that using a global variable for the normal speed ... I will rephrase the question: Is this (the code from the first post) the way to reduce player's speed when overlaping an object or is there a better way (another events) ?

  • Compare to my normal skills I think this way would be OK, or maybe you could use player position instead, find the coordinates of where the stairs are located, for example starts at x 100 and ends at x 200, so when player position is between X1 and X2, reduce speed, Else, set speed to normal. I actually do not know if this would work but theoretically it sounds ok, also it would help performance since it is not a collision detection event. And if there are any better ways for this to be done, I currently do not know them

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