In this tutorial you learn how to set up a spline to do so without writing a line of code. For this tutorial we will create a spline path.
Watch the video: https://youtu.be/vJznXRbQ9UU
- Start by creating a new map and placing a camera.
- Then place a pivot in your scene (Video tutorial if you don't know about pivots.).
- Go to its script tab and click select.
- Browse to the spline tool package and select the "Editor/EditorSpline.lua" lua script.
- By default the spline type is set to "Path", which is exactly what we need for this tutorial.
- Turn on all checkboxes that say "Debug"
- Drag the scene camera from the scene tree on to the "Debug camera" script property. Without doing this, the debug options won't work.
- Now lets create the nodes of this path. In the spline tools package you can find a prefabs folder which contains a "PathNode.pfd". Drag the prefab in the scene. Give it a usefull name and optionally, make it a child of the spline path pivot. Note: Although making it a child of the spline node is not mandatory, it does help organise your scene.
- Lets have a look at what this 'PathNode' is. It is actually exist out of: - 1 "PathNode" pivot. A path node script is attached to it. - 2 sub pivots called "A" and "B". These subpivots are called the "handlers" and have the function of curing the spline. Do not rename them, as the spline looks for entities with those names.
- Set the "Segments" property to 10. PathNode1 now looks like this:
- Copy the PathNode and give it a new name. For instance "PathNode2."
- Place PathNode2 a litlle further away from the first node. (10.000 centimeters or so)
- Select PathNode1, go the script tab if it is not opened. Now drag PathNode2 from the scene tree, in to the "Next node" property.
- Run the game. You will see the spline being drawn in your map with the help of the debug options. Notice how it is a straigt line though!
- In order to get (bezier) curves we need to start playing with the A and B handlers of a node.
- The "A" handler determines the outgoing handler (Little trick: "A" could be short for "Away") and B determines the incoming spline handler.
- For PathNode1 drag the the A handler away from the node. Move it halfway towards PathNode2 and then some more the the right, so that it looks a little like in the image below. The prefab nodes have a light blue color, while the handlers are pink. If you turn on debug options, these same colors are used.
- For PathNode 2, we do a similar thing. Drag handler B away from the node.
- If you run the game now you will see how the Spline is being bend towards the handlers.
- You can continue extending this spline by placing new PathNodes and linking them to previous nodes.
Now you know how to set up a spline with Aggror's Spline Tools. So whether this is a path, a road or a rope, the same technique is applied. In a follow up tutorial you learn how to move objects along the splines.