- Home /
Moving character around globe (Issue with transform)
I have a faux gravity system set up which is working great, it takes care of the object rotation so that it always stands on the 'planet' the right way up. The issue I'm having is moving the object. I don't want to use rigidbidy.AddForce as from my use of it the motion can become slippy and sluggish. I've tried using TransformDirection to turn the transform values from local to world space and applying those like so:
Vector3 forwardVector = this.transform.TransformDirection(Vector3.forward); Vector3 rightVector = this.transform.TransformDirection(Vector3.right); this.transform.localPosition += forwardVector * VerticalForce; this.transform.localPosition += rightVector * HorizontalForce;
but this seems to result in the object moving at a tangent around the planet. As the object's rotation is working correctly I thought it's forward and right vectors would be fine to use. Could someone help me please?
EDIT: I also had the planet spinning slowly on the spot to cause the illusion of orbit in relation to the skybox (all planetbound objects spin as part of it as they are children of it). Stopping the orbit script seems to have prevented the tangential movement but there is still a problem, after a small amount of movement the object gets stuck as if moving would cause too much of a collision between the planet and the player.
Okay I seem to have fixed the issue with it getting stuck by using rigidbody.AddForce. I shied away from this originally because the object was slippy in its movement but I now realise that is due to the Physics material. I now just need to find a material setting that works.