Ive got a platform that goes up and down following the sin behavior and adding a certain magnitude.

I've got the platform atm moving in a vertical motion but i want to make it vary in the speed.

Any advice for this problem?

8 posts
• Page **1** of **1**

**Posts:**31**Reputation:**2,446

B

7
S

2
G

3
In you event sheet add something like

every X seconds -- set sine period to Sprite to random(range required)

or, maybe better ?

every X seconds -- set sine period to Sprite to Sprite.Sine.Period+random(4)-2 (which will alter the period by +/- 2 seconds

you might also want to set some limits so it doesn't get too fast/slow

(not tested)

every X seconds -- set sine period to Sprite to random(range required)

or, maybe better ?

every X seconds -- set sine period to Sprite to Sprite.Sine.Period+random(4)-2 (which will alter the period by +/- 2 seconds

you might also want to set some limits so it doesn't get too fast/slow

(not tested)

August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/

**Posts:**1,194**Reputation:**30,812

B

64
S

33
G

47
https://www.youtube.com/watch?v=gENVB6tjq_M

I don't use the built-in behaviors, so this is how I would do it.

One way to write the wave equation is:

D(x,t) = A sin(kx - wt + [theta])

where w = 2(pi)f

D is the displacement from the center, k is the spring constant, x is the x position on the wave, w is [2*pi*f], f is the frequency, t is the time, and theta is the phase angle.

Since we're only concerned with one spot on the wave and not the entire thing we can let theta be zero and x be pi/2 (the maximum of a sin wave). However, if you had multiple objects you wanted to randomly wave together but not in perfect sync the easiest way to accomplish this would be by playing with the phase angle.

Now, for the behavior you asked for, I think the easiest approach would be to vary the spring constant k and not the time t. All you would need to do is solve the wave equation on every frame (remember to use a proper delta-time value and calculate the current time rather than just counting frames) and move your object to whatever displacement you come up with. When you want to change how fast it's moving you can change the spring constant k value (which isn't so constant in this case....) and it'll start moving at the new speed on its own.

I don't use the built-in behaviors, so this is how I would do it.

One way to write the wave equation is:

D(x,t) = A sin(kx - wt + [theta])

where w = 2(pi)f

D is the displacement from the center, k is the spring constant, x is the x position on the wave, w is [2*pi*f], f is the frequency, t is the time, and theta is the phase angle.

Since we're only concerned with one spot on the wave and not the entire thing we can let theta be zero and x be pi/2 (the maximum of a sin wave). However, if you had multiple objects you wanted to randomly wave together but not in perfect sync the easiest way to accomplish this would be by playing with the phase angle.

Now, for the behavior you asked for, I think the easiest approach would be to vary the spring constant k and not the time t. All you would need to do is solve the wave equation on every frame (remember to use a proper delta-time value and calculate the current time rather than just counting frames) and move your object to whatever displacement you come up with. When you want to change how fast it's moving you can change the spring constant k value (which isn't so constant in this case....) and it'll start moving at the new speed on its own.

**Posts:**37**Reputation:**749

B

9
S

3
now tested...

(latest beta can be found at the bottom of most pages)

(latest beta can be found at the bottom of most pages)

You do not have the required permissions to view the files attached to this post.

August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/

**Posts:**1,194**Reputation:**30,812

B

64
S

33
G

47
8 posts
• Page **1** of **1**

## Who is online |

Users browsing this forum: jasontoups, OddConfection and 3 guests |