updated capx

once the "X" leaves the dotted circle, the blue pointer jumps(rotates) too fast toward the X, would love to figure a way for the pointer to: ease into the rotation, increase speed midway, then near the end, slow down...

14 posts
• Page **2** of **2** • 1, **2**

updated capx

once the "X" leaves the dotted circle, the blue pointer jumps(rotates) too fast toward the X, would love to figure a way for the pointer to: ease into the rotation, increase speed midway, then near the end, slow down...

once the "X" leaves the dotted circle, the blue pointer jumps(rotates) too fast toward the X, would love to figure a way for the pointer to: ease into the rotation, increase speed midway, then near the end, slow down...

Steam: http://steamcommunity.com/sharedfiles/f ... =642927367 Construct 2 Creations Forum: viewtopic.php?f=180&t=170072

**Posts:**1,198**Reputation:**16,178

B

97
S

32
G

15
okay, update..

I was able to make it better, but it's still not quite right.. it's definitely better.. but there must be a real way to do it.

Every Tick Set Pointer.angle_diff_to_x to anglediff(Self.Angle,angle(self.X,self.Y,PointToThis.X,PointToThis.Y))

T=min(abs(self.anglediff_to_x - 180) * (0.02/180),1)

Pointer Set Angle: anglelerp(self.Angle,angle(self.X,self.Y,PointToThis.X,PointToThis.Y),T)

This is nightmarish.. I'm spending days and days just trying to get the movement right... ready to scrap it a design a different movement...

I was able to make it better, but it's still not quite right.. it's definitely better.. but there must be a real way to do it.

Every Tick Set Pointer.angle_diff_to_x to anglediff(Self.Angle,angle(self.X,self.Y,PointToThis.X,PointToThis.Y))

T=min(abs(self.anglediff_to_x - 180) * (0.02/180),1)

Pointer Set Angle: anglelerp(self.Angle,angle(self.X,self.Y,PointToThis.X,PointToThis.Y),T)

This is nightmarish.. I'm spending days and days just trying to get the movement right... ready to scrap it a design a different movement...

Steam: http://steamcommunity.com/sharedfiles/f ... =642927367 Construct 2 Creations Forum: viewtopic.php?f=180&t=170072

**Posts:**1,198**Reputation:**16,178

B

97
S

32
G

15
@jobel

You can't do it with just one formula, you need a variable that you change over time to do it.

One you could use is speed. It starts as 0 and it increases over time so you get an easing in effect.

Add 100*dt to speed

rotate self.speed*dt degrees toward target_angle

In the actions above the 100 is the acceleration.

You can also make an easing out effect with it by giving speed an initial speed and using negative acceleration to slow it down.

Set speed to max(self.speed-100*dt, 0)

rotate self.speed*dt degrees toward target_angle

The max() is used above so the speed never becomes negative. The one problem is you need to handle is if the start speed is too low the sprite will stop short. To fix that we can calculate what the speed should start at with:

speed= sqrt(anglediff(self.angle, target_angle)*2*100)

Or instead of 100 use whatever you're using as an acceleration.

Next to do an easing in-out effect (which is basically what the first capx I posted) you can accelerate or deccelerate depending on the stopping distance which can be calculated with:

dist = (speed^2)/(2*acceleration)

So then it can be reduced to two actions as follows:

global number acceleration=100

global number target_angle =270

every tick:

--- set speed to max(0,(((self.speed^2)/(2*acceleration)<anglediff(self.angle, target_angle))?acceleration:-)acceleration)

--- rotate self.speed*dt degrees toward target_angle

You may also want to reset the speed to 0 when the target is reached.

Here's a capx:

https://dl.dropboxusercontent.com/u/542 ... n_out.capx

It differs from the first capx in that it doesn't try to be physically accurate.

You can't do it with just one formula, you need a variable that you change over time to do it.

One you could use is speed. It starts as 0 and it increases over time so you get an easing in effect.

Add 100*dt to speed

rotate self.speed*dt degrees toward target_angle

In the actions above the 100 is the acceleration.

You can also make an easing out effect with it by giving speed an initial speed and using negative acceleration to slow it down.

Set speed to max(self.speed-100*dt, 0)

rotate self.speed*dt degrees toward target_angle

The max() is used above so the speed never becomes negative. The one problem is you need to handle is if the start speed is too low the sprite will stop short. To fix that we can calculate what the speed should start at with:

speed= sqrt(anglediff(self.angle, target_angle)*2*100)

Or instead of 100 use whatever you're using as an acceleration.

Next to do an easing in-out effect (which is basically what the first capx I posted) you can accelerate or deccelerate depending on the stopping distance which can be calculated with:

dist = (speed^2)/(2*acceleration)

So then it can be reduced to two actions as follows:

global number acceleration=100

global number target_angle =270

every tick:

--- set speed to max(0,(((self.speed^2)/(2*acceleration)<anglediff(self.angle, target_angle))?acceleration:-)acceleration)

--- rotate self.speed*dt degrees toward target_angle

You may also want to reset the speed to 0 when the target is reached.

Here's a capx:

https://dl.dropboxusercontent.com/u/542 ... n_out.capx

It differs from the first capx in that it doesn't try to be physically accurate.

**Posts:**5,274**Reputation:**69,959

B

92
S

32
G

107
Thanks @R0J0hound I'll check it out! (I very much appreciate the help!)

Steam: http://steamcommunity.com/sharedfiles/f ... =642927367 Construct 2 Creations Forum: viewtopic.php?f=180&t=170072

**Posts:**1,198**Reputation:**16,178

B

97
S

32
G

15
14 posts
• Page **2** of **2** • 1, **2**

## Who is online |

Users browsing this forum: AndreasR, Artepi, karthikavnair, OBLIVION, Rable and 15 guests |