- Home /
Round Planets and Movement on them
For a game I am making I need a way to move along a round surface and have a poll to the center. I need a few thing, I need to be able to fall towards the planet, I need to move across the planets surface without going off in odd directions, and I need for "Up" to be away from the center at all times.
I have googled this in every way I can, and the only things I found caused more issues then fixed. It has come to the point where I am sure there is no way to have a round game world!
Ah, so if you're that sure, why do you even ask? Got you...
Answer by HappyMoo · Jan 14, 2014 at 05:19 AM
These guys talk a bit about the problem: http://www.youtube.com/watch?v=wTFvlzLvIPs
I wouldn't do 3D gravity pointing to the planet center, but calculate the gravity force as a float and only in the last step apply it in the direction of the center of the planet. You're basically managing the players height above planet ground as if if was 2D, just that your negative y coordinate is pointing to the center at all times.
Also rotate the player, so his feet always point to the center and then you just basically apply horizontal and vertical movement, but from the players perspective.
Watch out that you don't use euler angles anywhere or gimbal lock will bite you.
Answer by getyour411 · Jan 14, 2014 at 06:43 AM
I happen to be working on the same thing for my game and got it working with the help of this post http://answers.unity3d.com/questions/613676/apply-a-new-vector3up-to-adjust-player-normal.html
While I don't use the JumptoWall stuff yet, the other code provides what I needed to walk around my somewhat spherical model 360degrees. I was able to modify it such that I didn't need my player to be a child of the boxcollider/rigidbody object, I just added those to the player and turn them on/off when I need them or don't.