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

Get help using Construct 2

Post » Sat Apr 26, 2014 7:40 pm

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:
Image

The problem is that the second event (player is not overlapping stairs) is executed at the very start and increases player's movement speed.
B
49
S
15
G
6
Posts: 534
Reputation: 7,195

Post » Sat Apr 26, 2014 7:50 pm

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.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
134
S
30
G
84
Posts: 5,391
Reputation: 58,464

Post » Sat Apr 26, 2014 7:53 pm

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.
B
12
S
3
G
1
Posts: 188
Reputation: 1,377

Post » Sat Apr 26, 2014 9:12 pm

@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 :)
B
49
S
15
G
6
Posts: 534
Reputation: 7,195

Post » Sun Apr 27, 2014 5:15 am

(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.
Image Stoorn Memory Puzzle
B
9
S
3
G
1
Posts: 66
Reputation: 1,488

Post » Sun Apr 27, 2014 4:44 pm

Phuzz wrote:(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) ?
B
49
S
15
G
6
Posts: 534
Reputation: 7,195

Post » Sun Apr 27, 2014 5:58 pm

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 ;)
Image Stoorn Memory Puzzle
B
9
S
3
G
1
Posts: 66
Reputation: 1,488


Return to How do I....?

Who is online

Users browsing this forum: Bootfit, OBLIVION and 24 guests