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
0
Question by thraxST · Mar 25, 2014 at 04:54 PM · vector3slerpcurved path

Interpolating along an arc.

I am trying to move an object between two points along an arc with respect to another point. I have a starting point A, an end point B and third point C. I want to make my object move from A to B along an curved path where the convex side of the path is facing away from point C.

I tried using Vector3.Slerp as shown in the documentation and I can get the curved path, but sometimes the path is flipped and the object goes through C.

My code is very similar to this example. How can I get the path to always be go away from C?

Comment
Add comment · Show 2
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 robertbu · Mar 26, 2014 at 05:23 AM 0
Share

Is this 2D or 3D. Are points A and B equal distant from point C? An example that fails might help get an answer.

avatar image thraxST · Mar 26, 2014 at 12:58 PM 0
Share

They are 3d points. I would have to test it out some more to come up with points that caused it.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by darthtelle · Mar 26, 2014 at 11:57 AM

You should use a Bezier curve if you have a third influential point. It includes a curve script which plots the points of the curve, however with a bit of alteration it can be used similar to lerping (without using the Vector3.Lerp function). Just substitue 't' for your timer.

 Vector3 bezierPosition = (((1 - timer) * (1 - timer)) * m_StartPosition) + (((1 - timer) * 2.0f) * timer * m_CurvePosition) + ((timer * timer) * m_TargetPosition);


Comment
Add comment · Show 2 · 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 thraxST · Mar 26, 2014 at 01:12 PM 0
Share

I took a look at this and in the examples given the third influential point is on the wrong side of the curve. Also, I got strange results when testing the formula you suggested. It does curve between the two points, but it doesn't always curve away from the influential point and sometimes create very large curves between points close together.

avatar image darthtelle · Mar 26, 2014 at 01:45 PM 0
Share

Ah, with bezier curves they curve towards the influential point. Perhaps if you find a similar point on the side you wish to curve towards it'll fit more to what you're looking for. Alternatively, you could use a sin or cos wave to create a path. Use a sin/cos similar to lerping but only affecting the x and z positions (or whichever axis the path moves along).

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

21 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Vector3.Slerp leads to wrong axis rotation 1 Answer

LookRotation Vector3 is Zero, Yet Slerp Still Rotates? 2 Answers

How can I Vector3 Slerp or Lerp locally? 3 Answers

Activating 3 rotations based on multiple presses on one key 2 Answers

What am I doing wrong with these rotations? 0 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