Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Control point rotation
#1
Hi,
Posted the topic over in the unity forum here:
http://forum.unity3d.com/threads/released-curvy-2-the-ultimate-spline-solution.358011/page-4

I want the object to use the path for positioning but the control points for rotation (so the rotation is the mix of the previous and next control points. E.g. if I'm .25% of the way from the previous to the next point it would be something like (Psudo code): Rotation == PreviousPoint.Rotation *.25 + NextPoint.Rotation *.75 /2 = MyControllerRotation.


To see an image of what I'm trying to achieve take a look at the attachements


Thanks


Attached Files Thumbnail(s)
           
Reply
#2
As bac9-flcl said, you're setup looks good for what you're after. If setting Spline's Orientation to static results in unwanted rotations, set it back to Dynamic and make some or all CP's orientation anchors, that might result in a better "flow". Orientation anchor means the dynamic orientation uses the CP's transform as a target while keeping the orientation flow continuous.
Reply
#3
(03-18-2016, 08:23 PM)Jake Wrote: As bac9-flcl said, you're setup looks good for what you're after. If setting Spline's Orientation to static results in unwanted rotations, set it back to Dynamic and make some or all CP's orientation anchors, that might result in a better "flow". Orientation anchor means the dynamic orientation uses the CP's transform as a target while keeping the orientation flow continuous.

If my settings are correct then the package is not working as I understand it should... 

I took another screenshot:

   

 If the package was working the front of the ship should have rotated so that it is facing the Z axis on the selected control point in the attached picture.   Nothing I've tried will make the front of the ship rotate off axis with the spline.  Furthermore no Curvy example has this behavior.  I'm not clear why if my settings are correct I'm not getting the behavior I want? Does the package not support this behavior?
Reply
#4
Can you please compare the ship's orientation in relation to the spline's orientation (yellow lines, you can increase line size in the preferences!)? They're too small to see it clearly on the image.

What perhaps adds confusion is that the up-vector always is perpendicular to the tangent(direction) of the spline. It can only rotate around the tangent at a given position. Usually this is what people expect when moving objects along a spline.

If that's not what you want, you can create a custom controller and override the ApplyTransformRotation() method. E.g. you can find the last and next CP there and lerp between their rotation etc...

Does that help?
Reply
#5
(03-22-2016, 10:03 PM)Jake Wrote: Can you please compare the ship's orientation in relation to the spline's orientation (yellow lines, you can increase line size in the preferences!)? They're too small to see it clearly on the image.

What perhaps adds confusion is that the up-vector always is perpendicular to the tangent(direction) of the spline. It can only rotate around the tangent at a given position. Usually this is what people expect when moving objects along a spline.

If that's not what you want, you can create a custom controller and override the ApplyTransformRotation() method. E.g. you can find the last and next CP there and lerp between their rotation etc...

Does that help?

Yes I need to create  custom controller then as I don't want it to rotate around the tangent of the spline.  Could I ask if there is a function to call to find my relative position between two points on the spline?  E.g.  A function that returns that I am  .X% along the current spline segment?  If so I can get this working quickly.

Thanks!
Reply
#6
SplineController.RelativePosition gives you the TF on the spline. You then can use Spline.TFToSegment() to get the local F inside a segment.

A more advanced approach would be to use Metadata. Basically you create a Metadata class and override the method that returns the lerped value. You then can add Metadata classes to your CP's and use Spline API to get interpolated values with ease, "error"-handling (like CP's without Metadata attached etc.) included.

See the Metadata example, and examine the metadata class used for the ship's height as well as the custom controller to apply the height. You can adapt that with ease to return a vector3 or quaternion instead of a float.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Avoiding runtime GC allocations on control point position change Ell223 8 18 02-24-2024, 10:43 AM
Last Post: _Aka_
Exclamation bad rotation aloriza 5 13 11-29-2023, 09:52 AM
Last Post: _Aka_
  Connection "next' control point jh092 3 15 11-22-2023, 11:47 AM
Last Post: _Aka_
  Spline.Length not updated unless I add a point to spline (or modify it) first. _RicO 3 6 08-26-2023, 08:41 AM
Last Post: _Aka_

Forum Jump: