Math question

0 favourites
  • 3 posts
From the Asset Store
Aliens are invading our planet! Solve the math question, and attack the alien with your laser. Covers addition, subtract
  • Hello all!

    I am looking for a way to design a scalar that goes from -1 to 1 dependent on the rotation of an object.

    Essentially:

    90 = -1

    180 = 1

    270 = -1

    0/360 = 1

    How might I go about this? Math is not my strong suit and any help is appreciated!!

    Edit: I realize a scalar may be the incorrect name for something like this, but I'm not sure what the correct term would be. Happy to learn!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could utilize sin(), it goes from -1 to 1 as well as smoothly inbetween.

    So you’d start with

    Sin(x)

    Shift it over so when x=0 it will be 1

    Sin(x+90)

    Next change it so it goes from -1 to 1 every 90 instead of 180.

    Sin(2*x+90)

    You could also use cos() instead. It’s just 90 off from sin()

    Cos(2*x)

    If you don’t want the smooth transitions inbetween you could utilize some rounding.

    Cos(2*round(x/90)*90)

    Hope that helps.

  • Thank you R0J0hound ! That sounds like exactly what I'm hoping for. Thank you for your help!

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