- Home /

# Move Object allong an ellipsoid path

Hi,

I'm new to Unity and whats even worse for this case of situation, not that good in mathematics :).

So my problem is, I want to move an Object with the cursor keys (left, right) or with a gamepad allong an ellipsoid path on the screen.

The screen center is also the center of the ellipse. The object should always look to the center of the ellipse (ok, I already know how to do that).

So can anybody with mathematical magic fingers tell me how the calculation for the position of the object that should move along the ellipse is?

An example script would be welcome. I'm planning to use c#, but a js script would just be as fine.

Thx alot, K

what is that alpha if it is an angle how it takes a angle in ellipse please explain about alpha is that a keyword

**Answer** by Wotan
·
Sep 18, 2010 at 04:02 PM

The mathematics is pretty simple, have a look at wikipedia.

You need to define your ellipse with a few parameters:

```
x, y: center of the ellipse
a, b: semimajor and semiminor axes
```

If you want to move on the elipses this means that you change the angle between the major axes and your position on the ellipse. Lets call this angle alpha.

Your position (X,Y) is:

```
X = x + (a * Math.cos(alpha));
Y = y + (b * Math.sin(alpha));
```

In order to move left or right you need to increase/decrease alpha and then recalculate your position.

Not the right place for a thank you... Good ideas for thanking answerers: http://meta.stackoverflow.com/questions/17878/stack-overflow-etiquette-for-thanking-users-who-answered-my-question

It works fine, but how to move the object when the ellipse path is diagonal?

With the formula given in the answer. Set the semiminor and semimajor axis to whatever you want and the ellipse will be oriented based on them.

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.

### Follow this Question

### Related Questions

Best Way to make a character move 1 Answer

Why won't my guy move forward/back? 2 Answers

Problems In Flocking Algorithm 1 Answer

My controls are inverted when facing sideways. 1 Answer

Sprint Script Error?!!!! 4 Answers