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 Magic_Nano · Aug 05, 2021 at 11:29 PM · camera followfollow playerformulacurved path

I can't figure out the correct formula of t (bezier curve)

As in the title, I can figure out the formula of float T.

The idea is that the camera follows the target and is always parallel to it, but also want the camera respects the curve. I know T is → float t = something / curveLength but I don't know the something alt text

I have the position of P1, P2, Tan (Green circle), Camera and followTarget (Orange diamond).

alt text Also can follow with complex forms.

imagen-2021-08-05-192315.png (19.3 kB)
captura-de-pantalla-2021-08-05-182637.png (14.5 kB)
Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · Aug 06, 2021 at 02:04 AM

Well this is a non-trivial problem and depending on the actual requirements doesn't have a direct solution. First of all you should clarify what you mean by "parallel". Only lines can be parallel. So if you have another line that line could be parallel to the tangent line on the curve. Maybe you want the camera to be at a 90° angle to the curve? Maybe you want it at the closest point on the curve? Maybe some other linear projection (onto the x or y axis? So the camera and point should have the same x or y coordinate?)


Next question is, do we only talk about 2d or 3d? 2d makes a lot things a bit easier. Unrelated to the coordinate space, do we only talk about a single quadratic bezier curve? Or do consider using cubic bezier curves (or even higher degree) as well?


Just to illustrate the problem: The quadratic bezier equation is of course a quadratic polynomial. To find the closest point on the curve we need to construct the distance equation in relation to t. This will turn the equation into a polynomial of degree 4. In order to find the minimum we need the first derivative of that equation which would give us a cubic equation that need to be solved. While this is doable it's not that simple. However if we talk about a cubic bezier, the distance equation would be a polinomial of degree 6 and the first derivative an order 5 polynomial. There is simply no direct solution to solve such an equation. However there are iterative approximation algorithms. Over here you can find some reference material. Though keep in mind that a polynomial of degree 3 has 3 potential solutions and degree 5 of course 5 potential solutions. So it's still up to you to pick one of the solutions that fits your requirements.


As I said, this was just an example when we talk about finding the closest point on the curve. While a quadratic bezier is relatively simple, a cubic or higher degree allows self-intersection and overlapping which will create many ambigous situations which can not be solved mathematically but may requires additional state tracking to find the most reasonable solution.


The two examples you've shown doesn't seem to match any of the above mentioned casaes. Your camera is not at the position 90° to the curve, it isn't aligned on x or y and it's not at the closest point on the curve. So to me it's not really clear whether the images you've shown illustrate actual examples or if they should just explain the situation. In any case I think you should clarify what exact behaviour you're expecting.


ps: If you're just look for a reasonable position on the curve for a certain player position, for quadratic bezier curves using the projected position between the start and end point of the curve as normalized "t" should work reasonably well, especially when the player moves around. The closest point in your second example would probably not behave that well.

Comment
Add comment · 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

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

126 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 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 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 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 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 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

camera problem 0 Answers

Complex Enemy follow AI 1 Answer

How do I make my camera follow selected player? 0 Answers

How do i fix choppy camera follow?,Choppy camera follow 1 Answer

Cinemachine Vcam follow problem 1 Answer


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