- Home /
Ho do I move an object on an elliptical path?
I need to move earth gameobject around sun in a ellipse path.
Please help.
Answer by victorvijay · Jun 22, 2011 at 12:20 PM
Sorry guys,got answer.
Based on ellipse equation we can ,make an object rotate in a elliptical path. The code I used is
var a : int;
var b : int;
var x: int;
var y : int;
var alpha : int;
var X : int;
var Y : int;
function Update () {
alpha += 10 ;
;
X = x + (a * Mathf.Cos(alpha*.005));
Y= y + (b * Mathf.Sin(alpha*.005));
this.gameObject.transform.position = Vector3(X,0,Y);
}
Use the 101010 button to format code.
If this is the answer that worked for you, mark it (the button with a check mark in it on the right hand side at the top of the question).
X,Y are very choppy like this, better Lerp the values for previous to current orso...
It works fine when the ellipse is horizontal or vertical. How to do it when the ellipse is diagonal?
Answer by TGKG · Jun 11, 2019 at 09:20 PM
Look here to determine the values a, b, x, y, alpha
https://gamedev.stackexchange.com/questions/9607/moving-an-object-in-a-circular-path/9610
Your answer
![](https://koobas.hobune.stream/wayback/20220612114406im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Move Object allong an ellipsoid path 1 Answer
Constant speed on elliptical path 0 Answers
Suborbital Missile Pathing 2 Answers
Drawing a moving objects trajectory 4 Answers