I need to move earth gameobject around sun in a ellipse path.
Please help.
I need to move earth gameobject around sun in a ellipse path.
Please help.
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);
}
Look here to determine the values a, b, x, y, alpha
mathematics - Moving an object in a circular path - Game Development Stack Exchange