Rotate a sprite around something such as another sprite?


#1

I want to make a spike ball rotate around a block, how do I achieve this?


#2

Create a new action, select your object and check out the position actions.


#3

I tried putting the object around the other but how do I make it so that it keeps rotating infinetely?


#4

The easiest way is to change the angle of your rotating sprite (increase it every frame, for example), and setting the rotation around the object to the angle of the rotating sprite:

Alternatively you can use a variable and update it every frame.


#5

or “change the angle of object: add 10” :blush:


#6

If the angle reaches 360, does it switch over to 10 or go on to 370 and up?

Because if it does, isn’t there a limit on how big a float or integer can be?
Because if the player for example, plays the game on their phone and leaves the phone on for a long time, could that specific action stop or crash.

Im just curious.:neutral_face::joy:


#7

Fair call, and a valid point, though once the limit is reached it would won’t crash, it’d cause an overflow. And the angle would start a very large negative value (see this NumberPhile explanation)

However, it would take quite a while to get there. But to prevent this, use the modulo operator/function, and set the rotate around angle to mod(OrbitingObject.Angle() + 10, 360)


#8

Ok cool. Thanks.
Now I know😁


#9

I think there’s some sort of automatic reset, if the angle is more than x, it subtracts 360.

Why not try yourself and see? Display it in a text object and find out.


#10

Yes, will do. For now Im just trying to figure out the best way to load and unload chunk’s in a randomly generated world