How do I write a Trigonometric Function?

0 favourites
  • 5 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • Hi,

    I have been working on a system that will set the temperature for my survival game. I want the temperature to fluctuate depending on the day over an 100 day period before repeating again. In order to get this to happen I want to use a Trigonometric formula to get this to work. The only problem is that the game system keeps telling me my function is missing something. Can anyone help?

    Tagged:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Guess it would help to show what you’re trying to use as a formula.

    Here’s one possible formula using sin() and the day as input. Every 100 days it will oscillate between 50 to 90.

    70+20*sin(day/100*360)

    Alternately you can use cosp() which interpolates between two values using a sine wave.

    cosp(50,90, day/100/2)

    The /2 was needed otherwise it would be 200 days for a full cycle.

  • Thanks this is working great now! The formula I was using was a standard y=A(B(sin-C))+D formula from trigonometry. This is what it looked like in the events: 36sin((pi/50)*Day))+55. Also I do have a question about the 100*360 part of the equation. If I were to make another formula, but I wanted a shorter interval before repeat, would I just change the 100 and keep the 360, or would I change them both.

  • Trig functions in construct use degrees instead of radians so you don’t have to use pi.

    And yeah you’d only change the 100.

  • Sweet, thanks so much

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