To prepare a spline curve to be used by the splineMgr
class, we can perform the following steps:
Create an empty GameObject, and set its position to (
0
,0
,0
). This will be the parent node to the collection of waypoints. Name it something appropriate, such ascurve1
.Create a series of spheres named
waypoint1
,waypoint2
, and so on. Note, we use GameObjects instead of empty objects so that we can enable the mesh renderer on the nodes if debugging or visualization is necessary. Our system will require a minimum of five points and two segments.Arrange these points in the editor so that they form an appealing curve that meets your needs. Note that we interpolate the position of the waypoints only, so rotating them will not impact the trajectory of the interpolation.
Create a GameObject that will be used to interpolate the curve. Name it
SplineObj
and assign it to theheadObj
reference of theSplineMgr
class.Create a
lineRenderer
component, and attach it to theheadObj...