Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
3
Question by KrisF · Sep 18, 2010 at 08:47 AM · javascriptmovementmoveellipse

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

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ibuchoco · Oct 12, 2014 at 08:51 AM 0
Share

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

1 Reply

· Add your reply
  • Sort: 
avatar image
4
Best Answer

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.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image KrisF · Sep 20, 2010 at 10:43 AM 0
Share

Thank you very much. It works just fine now :)

avatar image Herman-Tulleken KrisF · Sep 20, 2010 at 11:51 AM 0
Share

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

avatar image hyperzeta · Aug 13, 2016 at 11:25 AM 0
Share

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

avatar image NoseKills hyperzeta · Aug 13, 2016 at 12:29 PM 0
Share

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

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Movement in cycles? 0 Answers

Best Way to make a character move 1 Answer

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

Implementing Counter-Movement 0 Answers

Make so the script only moves and makes actions to the gameObject that its attached to. 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges