#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# Orbital move

Posts: 6Member, PRO
edited December 2017

Hi there!

I have a big problem with my orbital movement.
My character move on a circle “path” and with a button the player can change the radius of the circle.
I use for the movement the following expressions:

self.Position.X to: 230* sin( self.Time * 100%-360)+1104
and
self.Position.Y to: 230* cos( self.Time * 100%-360)+621

self.Position.X to: 330* sin( self.Time * 100%-360)+1104
and
self.Position.Y to: 330* cos( self.Time * 100%-360)+621

It works, but on a bigger circle the player speeds up.
I want to the character move with the same speed.

I have no idea how can I fix it.

• Posts: 11,335Member, Sous Chef, PRO, Senior Sous-Chef

The forum software messes up the formatting of asterisks (*) unless there is a space after them. I've edited your post to fix that problem.

New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

• London, UK.Posts: 12,821Member

@berczi17 said:
It works, but on a bigger circle the player speeds up.

Using the same multiple-of-self.time as the angle that sine and cosine are operating on - on both Radius values - means that the actor will always travel the same number of degrees per second (100° in your example) regardless of the radius of the orbit.

So if an actor is - for example - travelling at 90 degrees a second on a circle the size of a small coin it will take 4 seconds to orbit the whole coin, if the same actor was then travelling at 90 degrees a second on a circle the size of the moon it would still take 4 seconds to orbit the moon . . . . but of course it would have to be moving much much faster.

So . . . . you need to adjust the speed that the actor travels around the orbit to take into account the size of that orbit.

X = 230`*`sin(self.time`*`100)+1104
Y = 230`*`cos(self.time`*`100)+621
(no need for the modulo function)

This orbit is 1445 pixels long, so at 100°/s the actor is moving at 401pps.

So Radius 2 also needs to be progressing at 401pps.

X = 330`*`sin(self.time`*`100)+1104
Y = 330`*`cos(self.time`*`100)+621

This orbit is 2073 pixels long, divided by 401pps will give you the number of seconds it should take to complete the orbit . . . = 5.169s . . . . 360°/5.169s = 69.638°/s

X = 330`*`sin(self.time`*`69.638)+1104
Y = 330`*`cos(self.time`*`69.638)+621

• Posts: 6Member, PRO

I tried it before.
The problem is, when I use this methode, the character "spawn" to an incorrect place of the path.

"It's fall behind."

• London, UK.Posts: 12,821Member
edited December 2017

@berczi17 said:
I tried it before.
The problem is, when I use this methode, the character "spawn" to an incorrect place of the path.

"It's fall behind."

Yes, the angle . . . . X`*`cos(ANGLE) . . . would have changed.

So . . . .

Actor 1 'Controller' actor.
Rotate / Speed 100.

Actor 2 'Orbiting' actor.
X = 230`*`sin(Controller.rotation)+1104
Y = 230`*`cos(Controller.rotation)+621

When you change to Radius 2 . . . change the Orbiting actor's radius to 330 and change the controller actor's rotation speed to 69.638.

Note: place the 'Controller' actor lower - in the layers - than the orbiting actor.

• London, UK.Posts: 12,821Member
edited December 2017

A more efficient approach . . .

Game Attribute 'A'

Actor 1 'control' actor.
Rotate / Speed A.

Actor 2 'orbiting' actor.
X = 230+((100-A)`*`(10/3))`*`sin(control.rotation)+1104
Y = 230+((100-A)`*`(10/3))`*`cos(control.rotation)+621

. . . . . . .

Now you can change the rotation speed and radius at the same time by changing the attribute 'A' to either 100 or 70.

If A is 100 . . .
230+((100-A)`*`(10/3)) . . . . =
230+((100-100)`*`(3.33333)) . . . . =
230+(0`*`3.33333) . . . . =
230+(0) = 230

If A is 70
230+((100-A)`*`(10/3)) . . . . =
230+((100-70)`*`(3.33333)) . . . . =
230+(30`*`3.33333) . . . . =
230+(100) = 330

• Posts: 6Member, PRO
edited December 2017

@Socks

Thanks a lot!
It works perfectly.

.........

I have a little problem.
The actor change the radius immediately.
I want a little "fade" to the changing looks smoothly.

• London, UK.Posts: 12,821Member

@berczi17 said:
I have a little problem.
The actor change the radius immediately.
I want a little "fade" to the changing looks smoothly.

Interpolate A from 70 to 100.

• Posts: 6Member, PRO

@Socks

Thank you.

By the way in the 230+((100-A)*(10/3))
the "(10/3)" what is that mean?
I don't understand.

• London, UK.Posts: 12,821Member

@berczi17 said:
@Socks

Thank you.

By the way in the 230+((100-A)*(10/3))
the "(10/3)" what is that mean?
I don't understand.

10 divided by 3

or

10 ÷ 3

• Posts: 6Member, PRO

OK, but what is the 10 value and why must I dived by 3?

• London, UK.Posts: 12,821Member
edited December 2017

@berczi17 said:
OK, but what is the 10 value and why must I dived by 3?

"what is the 10 value"

10 is just 10 !

10 divided by 3 gives you 3.33333 . . . . (reoccurring).

"why must I dived by 3?"

Because 3.33333.... X 30 = 100.
. . . . . . . .

If A is 100 . . .
230+((100-A)*(10/3)) = 230

If A is 70
230+((100-A)*(10/3)) = 330

. . . . . . . .

It's just some simple maths to get 230 from 100 and - using the same equation - get 330 from 70. So you only need change a single value, 70 to 100, and the other values (230 and 330) automatically follow along.

• Posts: 6Member, PRO

@Socks

Thank you.