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

0 favourites
  • 4 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • 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?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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...

  • let's say

    Sprite startX=200

    sine magnitude=100

    so..

    sprite go to startX+sine magnitude(300) and then to startX-sine magnitude(100)..

  • 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 .

    BTW, a sine expresion that call top-left / Top-Right or similar will be useful XD

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