How do I check if object is moving left/right using sine?

Get help using Construct 2

Post » Sat Apr 16, 2016 10:35 am

I have a platform movement and i want check if is moving left or right to change their animation but i can't figure how to do that.

I tried retriving the current period/magnitude/value that changes but still not works correctly.

For example if value goes from -50 to 50 i make:

Greater than>0 animation right

Lower than <0 Animation left

But not works correctly because when moves to left when get the top will move to right staying in a <0 , so i have no idea how to check that ¿?

EDIT: I did it using detectors, but is there anyway to save that detectors each time i use an elevator and do it automatically?
B
25
S
10
G
3
Posts: 580
Reputation: 4,562

Post » Sat Apr 16, 2016 12:48 pm

You can use the CyclePosition. It goes from 0 to 1.
0 -> 0.25 is moving right. 0.25 -> 0.75 is moving left. 0.75 -> 1 is moving right again.

Unless the Period or Magnitude are negative...
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,670

Post » Sat Apr 16, 2016 7:37 pm

let's say
Sprite startX=200
sine magnitude=100
so..
sprite go to startX+sine magnitude(300) and then to startX-sine magnitude(100)..
B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072

Post » Sat Apr 16, 2016 8:12 pm

Playing with the debug i saw the "value" of the sine is the magnitude that works like:

Magnitude=34

Left: -34 / Center=0 / Right=34

But really never go to 34, always the max is some 33.999,etc...

So i put that when is less than -33 set animation to the right, and when is more than 33 set to the left, and works perfect.

To work in all platforms/evelators at any maginutde i created some expresions to get the magnitude value less one and now works perfect :P .

BTW, a sine expresion that call top-left / Top-Right or similar will be useful XD
B
25
S
10
G
3
Posts: 580
Reputation: 4,562


Return to How do I....?

Who is online

Users browsing this forum: kainrazial and 19 guests