Book Image

Creating E-Learning Games with Unity

By : David Horachek
Book Image

Creating E-Learning Games with Unity

By: David Horachek

Overview of this book

Table of Contents (17 chapters)
Creating E-Learning Games with Unity
About the Author
About the Reviewers

Connecting SplineMgr to NPCScript

To prepare a spline curve to be used by the splineMgr class, we can perform the following steps:

  1. 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 as curve1.

  2. 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.

  3. 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.

  4. Create a GameObject that will be used to interpolate the curve. Name it SplineObj and assign it to the headObj reference of the SplineMgr class.

  5. Create a lineRenderer component, and attach it to the headObj...