Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Spawning object with correct rotation at spline end
#1
Hi,

I'm trying to instantiate a drill bit prefab at the end of an oil drill line spline. The spline has 4 control points in total and I would like to instantiate the prefab at control point 4.

I have somehow gotten around instantiating the prefab at the right spot, but can't figure out from examples or API how to make it point to the same direction as the spline's point 4.

This is what I mean -

   

As the spline end point continuously changes it's facing direction, I want the yellow object (drill bit) to be facing the correct direction as the spline.

How do I go about this?
Reply
#2
I am writing this from the top of my head, it might have some minor errors:
Quaternion.LookAt(spline.GetTangent(1))
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Reply
#3
(05-21-2019, 12:35 PM)_Aka_ Wrote: I am writing this from the top of my head, it might have some minor errors:
Quaternion.LookAt(spline.GetTangent(1))

This did the trick! The line needs to be written "Quaternion.LookRotation(DestinationSpline.GetTangent(1))" and not LookAt. That's all and it worked.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Morph game object along curve. mikechr2000 5 326 02-04-2025, 09:30 PM
Last Post: _Aka_
  Disable a spline's gizmo when not selected or disabled. mikechr2000 1 141 02-03-2025, 09:34 AM
Last Post: _Aka_
Information Questions regarding spline colliders and collisions with rigidbodies Spyboticer 7 515 01-20-2025, 12:25 PM
Last Post: _Aka_
  Extrude mesh along spline. New and confused user GhostStalker 3 215 01-02-2025, 09:58 AM
Last Post: _Aka_

Forum Jump: