How can I create a circular movement with physics using velocity for a GameObject?
I want a rotating platform that can be interacted with the player, I also want to instantiate this platform passing a radius and speed to it to make the rotation bigger/smaller - faster/slower.
I watched some YouTube tutorials and read some stuff online about circular motion and I was able to KINDA of do it, check the gif below (or here: https://imgur.com/a/kAeV1BK):
The code for that is:
const increment = Math.PI / 36;
let degree = 0;
platform.update = (time, delta) => {
// increment the degree
degree += increment;
// calculate velocityY and velocityX
const velocityX = Math.cos(degree);
const velocityY = Math.sin(degree);
// set the body velocity
platform.body.setVelocity(
velocityX * 120,
velocityY * 120
);
};
The thing is, I have no control over the speed and size of the circle, that’s because I have almost no clue of what I did
Does anyone knows how to properly do it?
Thank you!