- Home /
RotateAround using physics
Hey,
I am working on a 2D game where the player jumps from planet to planet and runs around that planet. At the moment I am working on the running around the planet part. I gave the planet a Point Effector 2D to simulate gravity, only problem I am having is that I want my player to run around the planet in a continuous speed. I could achieve this by using RotateAround() but when I try to apply jumping using AddForce() but then I get unexpected behaviour, where the player would be slowing down or speeding up at some points. What would be the best way to fix this while still using a Rigidbody? This is a small clip showing the issues. https://streamable.com/jmtly
Answer by LAZYGAMES_ · Jan 28, 2018 at 08:50 PM
Could you post your script that you are using to jump?
From the video I guess that you are adding force in a Vector up and right. But when the player gets added force to the right while rotating around the planet by RotateAround then the player will speed up as more force is added to the velocity the player already has.
Try to just apply force up as the player is moving sideways anyway.
Currently I am probably using an odd way that is guaranteed to fail. I am using transform.RotateAround(planet.position, -transform.forward, movementSpeed * Time.deltaTime);
and to jump I am using rb.AddForce(transform.up);
. I know its not good to combine transform and forces, but I don't know how to make it rotate around the planet with forces.
You have disabled the normal downforce of unity right? But if you want your player to just jump once and dont do double jumps your solution seems to work. If want the player to just jump once add a Collider on the player and check if he is grounded. the add the force to the player if he presses "jump" and is grounded.
I want it to be able to fly around the planet aswell like it is doing in the video. Only problem is that the player keeps slowing down and speeding up. I was guessing it is happening because I am using transform and physics at the same time. Do you know a way to get the rota$$anonymous$$round function but with physics ins$$anonymous$$d of using it directly on the transform.