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

berczi17
Posts: **6**Member, PRO

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:

Radius 1:

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

and

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

Radius 2:

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.

0

## Comments

11,335Member, Sous Chef, PRO, Senior Sous-ChefThe 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

12,821MemberUsing the

samemultiple-of-self.time as theanglethat 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

speedthat the actor travels around the orbit to take into account the size of that orbit.So Radius 1:

X = 230

`*`

sin(self.time`*`

100)+1104Y = 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.

Radius 2:

X = 330

`*`

sin(self.time`*`

100)+1104Y = 330

`*`

cos(self.time`*`

100)+621This 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

So Radius 2 should read:

X = 330

`*`

sin(self.time`*`

69.638)+1104Y = 330

`*`

cos(self.time`*`

69.638)+6216Member, PROThank you yours reply.

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."

12,821MemberYes, the angle . . . . X

`*`

cos(ANGLE) . . . would have changed.So . . . .

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

Actor 2'Orbiting' actor.Radius 1

X = 230

`*`

sin(Controller.rotation)+1104Y = 230

`*`

cos(Controller.rotation)+621When 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.

12,821MemberA 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)+1104Y = 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

6Member, PRO@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.

12,821MemberInterpolate A from 70 to 100.

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.

12,821Member10 divided by 3

or

10 ÷ 3

6Member, PROOK, but what is the 10 value and why must I dived by 3?

12,821Member"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)) =

230If A is

70230+((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.

6Member, PRO@Socks

Thank you.