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

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?
Reply
#2
Hi

(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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Does CurvySplines support displaying handles and points during runtime? niuage 1 7 12-11-2023, 12:01 PM
Last Post: _Aka_
  Programming a first-person player/camera to follow a Curvy Spline kenmarold 1 6 05-21-2023, 05:03 PM
Last Post: _Aka_
  Control handles gone for control points! :( danne_lindwall 3 5 02-10-2023, 08:49 AM
Last Post: _Aka_
  Missing Bezier Handles in Unity 2021.2.1f1 Flibble 3 213 11-20-2021, 05:08 PM
Last Post: _Aka_

Forum Jump: