- Home /
Create Circular Motion to follow the object
Hello, im new in unity and need help to create Circular Motion, i starting to create satellite motion and i would like do it, when satellite starting rotate round the earth should have Circular Motion to follow the satellite and show direction to satellite, i'll post some image show exctelly what i want, also i can have some example explain how upload music in unity3d, include music to simulation and start / stop music button. thanks
Answer by AlucardJay · Feb 25, 2013 at 04:40 PM
You can use Rotate as in the answer by robertblu (with the child satellite at an offset to the parent gameObject), or define a Vector3 to RotateAround : http://docs.unity3d.com/Documentation/ScriptReference/Transform.RotateAround.html
var target : Transform; // drop what you want the satellite to rotate around here in the inspector
var orbitSpeed : float = 10.0;
function Update()
{
transform.RotateAround( target.position, Vector3.up, orbitSpeed * Time.deltaTime );
}
Attach this script to your Satellite
In the Satellite Inspector, drag and drop the planet you wish the satellite to orbit around into the variable target
Check my answer here on Rotate and RotateAround : http://answers.unity3d.com/questions/323032/how-to-rotate-one-object-around-another-one.html
@alucardj: I believe he has the added problem that the satellite was authored with the center point not at the center of the object, so he will have the same issues with these solutions.
Aah thankyou, that explains the confusion in all the comments (now deleted). Anyway, both answers appear educational for future readers. All the best.
Answer by robertbu · Feb 21, 2013 at 05:56 PM
If I understand you correctly, you want to rotate the satellite around the planet?
Make an empty game object and place it at the center of the planet.
Position the satellite in orbit and then make it a child of the empty game object by dragging and dropping the satellite onto the empty game object in the Hierarchy view.
Rotate the empty game object a little bit each frame.
function Update() { transform.Rotate(Vector3(0,0,2)); }
Your answer
Follow this Question
Related Questions
colliders with touch 0 Answers
whole animation not being played 0 Answers
Show activity indicator in center of screen 0 Answers
ASDAsdASDasdqweqw3edqwdQWDEqwedQWD 3 Answers
accessing a variable from one script in another with Unity 1 Answer