- Home /
Having trouble with implementing circular player movement
Hello all. I'm pretty new to Unity and a complete beginner when it comes to programming, so I'm looking for some help with a problem I'm having.
I'm trying to create a control method whereby the player moves in a circular motion, along the path of a several concentric rings. I was able to get movement from ring to ring working, but I'm having trouble getting the circular motion working correctly.
After a couple of false starts I found a script here which seemed to be just what I needed. It works for the most part; however the problem I'm having is that any left/right movement will gradually cause the player to drift out of orbit.
Here's a web player link, it may describe the problem better than my summary.
I also tried an implementation whereby the player gameobject is parented by an object in the centre which does all of the rotation, causing the player to rotate around it; but this gives me trouble when changing the player's distance from the centre. The speed increases the farther out the player moves, which is undesirable, as I need the player to have a uniform movement speed. Web player example of this attempt.
Does anyone have a solution which could help?
Edit: Fixed links.
Thanks for reading,
Ben Wilson (zerofiftyone)
Your dropbox links are broken, so we cannot see what you are asking about.
Answer by flarespeed · Mar 04, 2014 at 06:21 PM
I would try making an equation which slowed the rotation of the parent GameObject relative to the circumference of the orbit.
"Rotation speed" = "Initial speed" / 2 π r
I think I got this equation right, not entirely sure. Symbol is pi, and r is the distance of the player from the center, in case anyone is confused.
A friend of $$anonymous$$e suggested that too. I will try it this evening once I get home from work. Thanks for your time.
I picked this project back up recently; currently remaking it in Unreal Engine. Anyway, just wanted to say thanks for your help! Revisiting this post saved me a lot of time otherwise spent figuring it out; I am the worst at maths.
Thanks again, Ben