How do I test for a direction change?

Get help using Construct 2

Post » Sun Dec 06, 2015 6:19 pm

I'd like to check if the player has changed direction, is it possible without messy variables to set and test directions?
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Sun Dec 06, 2015 6:44 pm

One variable and one event would usually do:

Give the player a variable oldAngle

player compare variable Oldangle is not player.angle
> Add your events
> set oldangle to player.angle
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun Dec 06, 2015 6:57 pm

That's actually a really good idea, I used PlayerObject.Platform.VectorX > 0 and Press Left Arrow or PlayerObject.Platform.VectorX < 0 and Press Right Arrow, I think your method might be better for controls that aren't just left or right so I'll try implementing it that way, shame C2 doesn't have a built-in test for direction change though!
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Sun Dec 06, 2015 9:29 pm

Well, because most of the time angles are changed by events, it isn't really nescessary..

This:

" PlayerObject.Platform.VectorX > 0 and Press Left Arrow or PlayerObject.Platform.VectorX < 0 and Press Right Arrow"

Sounds perfectly fine, but for something like that I'd use a state machine..
Also just one variable a textvariable set to "left" while moving left, "right" while moving right..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775


Return to How do I....?

Who is online

Users browsing this forum: blue visionary, namaewayukidesu and 12 guests