- Home /
How to draw an elliptical circle path for animated object?
Hi guys, I am new to unity3d world . I want to draw an elliptical circle path for my moving object My question how can I do this is there any way to generate the elliptical circle from mathematics equations and algorithms or should I create this path by 3dsmax. if you have any suggestion or any related tutorial please help
Do you want a visible path? Or do you just want an object to travel along an elliptical path?
I've asked a similar question: How to make computer controlled cars? I want the road to be visible(of course), but the path'd be hidden.
The'll be moving in a more complicated way though, but the answer should be similar, so pls reply to my answer too.
Answer by unimechanic · Jan 09, 2013 at 02:03 PM
You can use trigonometry to calculate the position of the object in the elliptical path, this way:
using UnityEngine;
using System.Collections;
public class EllipticalPathCS : MonoBehaviour {
public Vector3 center = new Vector3(0, 1, 0);
public float radiusA = 5;
public float radiusB = 10;
public float speed = 1;
private float angle;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
angle += speed * Time.deltaTime;
// Calculates position with parametric form, explanation:
// http://en.wikipedia.org/wiki/Ellipse#Parametric_form_in_canonical_position
float x = radiusA * Mathf.Cos(angle);
float y = radiusB * Mathf.Sin(angle);
transform.position = center + new Vector3(x, 0, y);
}
}
Your answer

Follow this Question
Related Questions
draw a path in game with touch and move player on it 0 Answers
Generating mesh - performance issues? 5 Answers
iTween : change path in current point 4 Answers
how to generate the path or road in unity 3d 1 Answer
path of xml file 1 Answer