Sine - On Max magnitude reached?

0 favourites
  • 4 posts
From the Asset Store
AppLovin MAX Ads ( Banner Ad, Interstitial Ad Rewarded Ad, MREC Ad)
  • Hi.

    Im experimenting with the Sine behavior.

    Take for example the 'Sine Behavior Types' project in Construct 2.

    Take the sprite in the top left corner with UID 0.

    How would YOU make that sprite pick a new random magnitude, every time it reaches the extreme of the current(As in, each time it goes to leftmost or rightmost side)?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Leftmost and rightmost positions are respectively at cycle position 0.25 and 0.75. You could use this information to modify the magnitude at will, however, cycle position can't really be tested with such fixed values. You need to test greater than/lesser than and use a boolean to switch the active condition. Second, magnitude shouldn't be changed at those moments, because it'll totally break the behavior... (I just tried <img src="smileys/smiley18.gif" border="0" align="middle">) BUT ! Changing the magnitude at cycle time 0 and 0.5 (when the sprite is centered) should do what you want.

    Here's the result :

  • Yea, works awesome that way, thanks! ^^

    One more question tho - Since the Magnitude is different, but the period is always the same, the speed of the movement varies a lot.

    Do you happen to know any formula for period that would make it's movement Period consistent with the Magnitude?

    As in, no matter how large of a magnitude you pick, the object wouldn't move any faster(in terms of pixels per second) across the screen?

    I'm guessing it's just about figuring out the ratio between the default Magnitude/Period and applying that ratio to the Period depending on new value?

  • Yup, you got it right ! I just re-uploaded the example with the implementation of such a ratio.

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