Clone wiki

SplineTools / Tutorial: Setting up a roadspline

In this tutorial you learn how to set up a road spline without a terrain. This is uses a very similar approach to the 'Setting up a spline path tutorial'. The only difference are the RoadNodes instead of PathNodes. You can also watch the Youtube tutorial.

  1. Start by creating a new map and placing a camera. You can either make it look at the splines you are going to create or attach the spectator script. Leadwerks has this script by deafult but you can also find it in the "Scripts/SplineTools/Editor/Helpers" folder.
  2. Then place a pivot in your scene (Video tutorial if you don't know about pivots.).
  3. Go to its script tab and click select.
  4. Browse to the spline tool package and select the "Editor/EditorSpline.lua" lua script.
  5. By default the spline type is set to "Path", so we set it to "Road".
  6. Turn on all checkboxes that say "Debug"
  7. Drag the scene camera from the scene tree on to the "Debug camera" script property. Without doing this, the debug options won't work.
  8. Now lets create the nodes of this path. In the spline tools package you can find a prefabs folder which contains a "RoadNode.pfb". 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.
  9. Lets have a look at what this 'RoadNode' is. It actually exist out of: - 1 "RoadNode" pivot. A roadnode.lua 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.
  10. Set the "Segments" property to 10.
  11. Set the "Road width" property to 2.
  12. Set a "Road material". Go to the folder "Scripts/SplineTools/Materials/Roads" and pick a road material. RoadNode1 now looks something like this <insert image>
  13. Copy RoadNode1 and give it a new name. Something super creative like "RoadNode2."
  14. Place RoadNode2 a litlle further away from the first node. (10.000 centimeters or so)
  15. Select RoadNode1, go the script tab if it is not opened. Now drag RoadNode2 from the scene tree, in to the "Next node" property.
  16. In order to get (bezier) curves we need to start playing with the A and B handlers of a node.
  17. The "A" handler determines the outgoing handler (Little trick: "A" could be short for "Away") and B determines the incoming spline handler.
  18. For RoadNode1 drag the the A handler away from the node. Move it halfway towards RoadNode2 and then some more the the right, so that it looks a little like in the image below. Nodes have a light blue color, while the handlers are pink. <insert image>
  19. For RoadNode 2, we do a similar thing. Drag handler B away from the node.
  20. If you run the game now you will see how the Road is being created.
  21. You can continue extending this spline by placing new PathNodes and linking them to previous nodes.

Now you know how to set up a road spline with Aggror's Spline Tools.

Updated