- Home /
Interactively moving a game object in a circle
I would like to be able to constrain character movement to a circle around another game object. How do I consrain my game object to a certain radius yet let the player control the movement of the object around the center?
Answer by Atnas1010 · Nov 01, 2010 at 01:02 AM
If I understand you right, you are looking for something like this:
var rotation : Quaternion;
var radius = Vector3(5,0,0);
var currentRotation = 0.0;
function Update()
{
currentRotation += Input.GetAxis("Horizontal")*Time.deltaTime*100;
rotation.eulerAngles = Vector3(0, currentRotation, 0);
transform.position = rotation * radius;
}
I placed this script on the object I want to rotate around another object but I can't seem to move it at all. Any ideas?
This was it. Sorry didn't realize I had to remove the script and re-add it. Thanks for the help.
Your answer
Follow this Question
Related Questions
How to make camera position relative to a specific target. 1 Answer
Player controller 0 Answers
Multiplayer game, terrain edit control for 2 characters 0 Answers
Network - Character Controls 1 Answer
mouse control with slower rotation 1 Answer