Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
2D CurvyUISpline, Orthographic Camera and Handles

I have an UI Canvas rendering into Camera, where Camera is orthographic projection with size 1 + CurvyUISpline + Control Points with manual handles.

Problem: The handles need to be very far far (read: not useable) away from the control point to change the bezier curvature. If they are "normally" close (useable), they do way to little effect to the curvature. To be able to edit the tangents in an useable way, I would need to change the projection size to e.g. 100. But I cannot do that because of the way how Unity's 2D physics work (e.g. the hinge joint physics are dependent on the projection size of the orthographic camera, as weird as this may sound; 100 projection size completely breaks hinge joint physics like with a rope). So, I must use a small orthographic projection size around 1-5. But with this, the splines' tangents are not useable.. loop..

Any idea how to fix this? A line of code to respect the cameras' orthographic size in calculating the curvatures' strength?

(06-15-2022, 08:41 AM)MichaelH82 Wrote: the hinge joint physics are dependent on the projection size of the orthographic camera, as weird as this may sound
Wow, Unity does not cease to amaze me Big Grin

To solve your issue, here is what I would recommand:
Go to DTHanldes.PositionHandle. You will see that it takes the current handle position, and returns the updated handle position (after it has been modified by user input). Those positions are absolute positions, not local to the Control Point (CP). I will come back to this later.
The idea is to modify that method so that it draws handles shorter than what they really are. This method will convert the input position into the "small scale space", then converts the output from the small scale space into the normal position. To do this conversion, you will need the position and rotation of the CP, since the scaling of the handles is to be done in the local space of the CP. Basically:
WorldSpaceHandlePosition = CpPosition + CpRotation * LocalHandlePosition
I hope this helped. Let me know if you need further explanation
Have a nice day
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.

Possibly Related Threads…
Thread Author Replies Views Last Post
  Missing Bezier Handles in Unity 2021.2.1f1 Flibble 3 213 11-20-2021, 05:08 PM
Last Post: _Aka_
  Camera wobbles on too long spline (100km+) Vectorvision 10 8,022 08-01-2019, 12:35 PM
Last Post: _Aka_
  Can I detect if the camera is looking to the left or right of the current heading? atomsinthevoid 1 3,202 01-12-2018, 05:55 PM
Last Post: _Aka_
  Moving several CPs and hide handles? Autarkis 1 3,164 09-11-2016, 04:33 PM
Last Post: Jake

Forum Jump: