User Manual
User Manual
User Manual
1
Dreamteck Splines – User Manual
Contents
1. Getting Started .......................................................................................................................................................... 8
1.1. Key Features ...................................................................................................................................................... 8
1.2. Install ................................................................................................................................................................. 8
1.3. Updating Dreamteck Splines ............................................................................................................................. 9
1.4. Preferences configuration................................................................................................................................. 9
1.5. Creating a new Spline........................................................................................................................................ 9
1.6. Adding control points...................................................................................................................................... 10
1.6.1. Placement Mode ..................................................................................................................................... 10
1.6.2. Normal Mode .......................................................................................................................................... 11
1.6.3. Append To ............................................................................................................................................... 11
1.6.4. Add Node ................................................................................................................................................ 12
1.7. Selecting points ............................................................................................................................................... 12
1.7.1. Selecting multiple points......................................................................................................................... 12
1.8. Deleting points ................................................................................................................................................ 13
1.9. Undo ................................................................................................................................................................ 13
2. Editing Splines ......................................................................................................................................................... 13
2.1. Move Tool (W) ................................................................................................................................................ 13
2.2. Rotate Tool (E) ................................................................................................................................................ 14
........................................................................................................................ 14
2
Dreamteck Splines – User Manual
7
Dreamteck Splines – User Manual
1. Getting Started
Dreamteck Splines is a Spline system and extension for Unity which comes with a collection of tools and
components for mesh generation, particle control, object spawning and much more. For a full list of features, refer
to Spline Users and Editor Tools. The tool was initially created to aid our company (Dreamteck Ltd.) in the process of
level editing and creating game mechanics and it has been growing ever since it was first created in 2013. Over the
years it has been used for many different purposes in many different projects (action games, TCG games, racing
games, endless runners, children’s games and more).
Our support team is always at your disposal to help resolve issues at https://dreamteck.io/support/contact.php
1.2. Install
After the Dreamteck Splines package is
downloaded from the Asset Store and imported into
the project, a welcome window will pop up with
information about the current version and additional
actions.
8
Dreamteck Splines – User Manual
If a previous version of Dreamteck Splines is installed, it is recommended that the previous version is
removed before updating. Before deleting the current Dreamteck Splines version, make sure that the
Dreamteck/Splines/Presets folder doesn’t contain any custom presets and if it does, make a backup of them.
The options under “Newly created splines” define the default settings for each newly created spline. For
example, if the game scene is full of light colors, then the default spline color could be set to black and that way
each newly created spline will be black upon creation without the need of setting the color every time.
The options under “Newly created points” define the size and color of newly created points.
The options under the “Editor” section let the user customize the UI and scene view of the editor.
9
Dreamteck Splines – User Manual
The point creation mode has a couple of properties which define how points are created and added to the
spline.
10
Dreamteck Splines – User Manual
• Surface – Creates points on any surface which has a 3D Collider (uses Raycasting)
All placement modes have an accompanying offset property. For the world plane methods, it is called the
“Grid Offset” and for the camera plane it’s called “Far Plane”. In surface mode it is called “Surface offset”. This
property adds offset along the given creation method’s normal.
• Default – Will use the default normal for the selected placement method. For example, Y Plane will
make the normal point upwards.
• Look at Camera – The normal will look towards the editor camera’s position
• Align with Camera – The normal will align with the editor camera’s direction
• Calculate – The normal will automatically be calculated based on the location of the previous control
points
• Left – World Negative X
• Right – World Positive X
• Up – World Positive Y
• Down – World Negative Y
• Forward – World Positive Z
• Back – World Negative Z
1.6.3. Append To
Defines to which end of the spline the new points will beaded.
• Beginning – Will add the point before the first spline point
• End – Will add the point after the last spline point
11
Dreamteck Splines – User Manual
Selected points are highlighted in blue by default and are drawn with an additional hollow circle surrounding
them:
12
Dreamteck Splines – User Manual
The Delete Mode toggles the delete brush tool. The brush tool has
a radius in which it looks for points. Clicking and holding while dragging
along the scene view will delete any spline points that fall under the
delete brush’ range.
1.9. Undo
Any action can be undone using Unity’s undo (Ctrl+Z) or re-done
(Ctrl+Y).
2. Editing Splines
A spline control point has a couple of properties:
These parameters can be edited quickly in a user-friendly editor, dedicated for that.
Once the control points of a spline are created, they can be edited one by one or together in a group.
The most basic editing mechanism is dragging the points directly inside the scene view when not in any of
the editor modes (Create, Delete, Move, Rotate, etc.). This moves the points along the camera plane so
when working in 3D it is recommended that a Top, Right or Forward perspective is used in the editor. If more
than one point is selected, when dragging a point on screen, the rest of the selected points will also move.
13
Dreamteck Splines – User Manual
The Edit Space property of the move tool defines how the handle will be oriented. World will orient the
handle along the world’s axis. Transform will orient the handle along the Spline Computer’s transform
rotation and “Spline” will orient the handle along the spline. Note that “Spline” edit space only works when a
single spline point is selected.
14
Dreamteck Splines – User Manual
The Scale tool will scale a single point’s tangents and size. When multiple points are selected, the points’
positions will also get scaled and offset based on their average center.
Similarly to the Rotate tool, scaling tangents and sizes can be toggled
on or off separately using the tool’s properties displayed under the
toolbar when the tool is selected.
The Normal Tool is a new kind of tool developed to ensure easy and intuitive normal editing for spline
points. It has two modes.
15
Dreamteck Splines – User Manual
The Mirror tool does what its name suggests – it duplicates and mirrors the spline points along a given
axis.
The mirror tool reflects the spline based on the mirror center which by default matches the position of
the SplineComputer’s Transform. If the symmetry center isn’t visible, make sure to look for it around the
computer’s transform position.
16
Dreamteck Splines – User Manual
the left of the center will be reflected to the right, otherwise the points on the right will be reflected to the
left.
The “Weld Distance” setting defines at what distance from the symmetry plane two reflected points will be
merged into one. If the spline is of Bezier type, the merged point will have broken tangents.
The Apply and Revert buttons are used to either finalize or revert the changes made with the mirror tool. If
the mirror tool is exited without clicking the Apply button, a dialog will appear asking if the made changes should
be kept or reverted.
2.6. Primitives
Dreamteck Splines provides a list of procedural primitives and a preset saving system. Both are located
in the Primitives & Presets tab inside the Edit panel (last button on the right).
Different primitives can be selected using the dropdown menu just bellow the Primitives button. Each
primitive has its own set of settings. Clicking “Apply” will save the primitive and make it into an editable
spline. Revert will revert the previous state of the spline.
The Create New button will create a new preset out of the current spline.
The Use button will use the currently selected preset from the dropdown menu. Delete will delete this
preset.
17
Dreamteck Splines – User Manual
Spline presets are saved as files under Dreamteck/Splines/Presets When updating the plugin version, it is
a good idea to backup this folder if custom presets are used.
If the spline type is Bezier, a dialog will appear upon selecting the flat operation giving the option to flat only the
points’ positions, only the points’ tangents or everything.
18
Dreamteck Splines – User Manual
Before:
After:
Once the Edit panel is closed, the editor tools will become available for the spline’s object.
19
Dreamteck Splines – User Manual
3.1. Type
The type of spline interpolation to be used. Dreamteck Splines supports four types of spline interpolation:
• Hermite
• Bezier
• B-Spline
• Linear
For the Bezier spline type, each point gets additional tangent points which control the interpolation of
the curve (connected with a dotted line).
3.2. Space
The coordinate system the spline should use:
• World – the spline uses world coordinates regardless of how the spline object’s transform is
positioned, oriented and scaled
• Local – the spline will transform with the object’s transform
20
Dreamteck Splines – User Manual
A lot of people who are new to splines encounter this issue when they try to extrude meshes or place
objects along splines as some regions are denser than others. To illustrate this, here is the spline, drawn with
thickness on:
Each vertical line represents a spline sample. In this case, there are 10 samples between points 1 and 2
but there are also 10 samples in between points 2 and 3.
This is how the Default sample mode works. It is the fastest one in terms of performance but if the
points are not distributed evenly, some spline regions may stretch or squash. There are three sample modes
in Dreamteck Splines:
• Uniform – distributes the samples evenly along the spline but is heavy especially for larger
splines
21
Dreamteck Splines – User Manual
Note that in Default and Optimized modes, when moving a control point, the splines only update the
samples in the region that is affected by the point. In Uniform mode, the entire spline is re-calculated.
In Optimized mode, an additional slider is presented to control the angle threshold for optimization.
• Update
• FixedUpdate
• LateUpdate
• AllUpdate – all three
• None – the spline will never update automatically during runtime and needs to be manually updated
by calling Rebuild()
22
Dreamteck Splines – User Manual
3.7. Multithreaded
Should the Spline Computer use a separate thread for calculating the samples? This is useful when either
the spline is big, the sample rate is very high, the sample mode is set to Optimized or Uniform or all of the
aforementioned.
Multithreaded splines might not update on the same frame. They usually lag one or two frames behind
but that is only noticeable if an in-game spline editing is presented to the player (if the player has control
over some spline points or properties).
Interpolation happens for the points’ sizes, colors and normals. By default, linear interpolation is used
but sometimes it is useful to have other types of interpolation. For example, when following a spline, it
might be a good idea to use an ease-in, ease-out curve for the normal interpolation if point normals point in
different directions.
This is how the size interpolation looks like when custom interpolation is used:
23
Dreamteck Splines – User Manual
4.2. Breaking
To break a closed spline, press the “Break” button. The first point of the spline will be separated into two
points.
Splines can also be broken at a different point. If a single point is selected when clicking “Break”, that point
will be separated.
24
Dreamteck Splines – User Manual
Clicking on either circle, will merge the given spline with the
currently selected one.
There are two options for merging. One is the merge side.
By default, the merge side is set to “End”, meaning that whichever
end is selected for the foreign spline, it will be merged to the
selected spline’s end point. Setting this option to “Start” will work
the other way around.
Switching to any of the tools from the Edit panel will deselect the currently selected transform tool
automatically.
25
Dreamteck Splines – User Manual
Expanding the Info & Debug panel, a couple options are presented:
• Color in Scene – The color of the spline used to draw it in the editor
• Always Draw Spline – Should the spline always be drawn regardless of whether it is selected?
• Draw Thickness – Toggling it draws the spline’s thickness, based on the control points’ sizes
When an object with a Spline User component is selected in the editor, the referenced spline is
automatically drawn.
Note that the Spline User component itself is rarely directly used since it doesn’t do anything. The Spline
User component is used as a base for the rest of the components that utilize the splines. In the following
chapters, various Spline User components are described.
26
Dreamteck Splines – User Manual
will be displayed in the inspector and the Spline User will not work.
Example in code:
The clip range is defined by the Clip From and Clip To values. By default, the editor displays the range with a
MinMax slider:
This type of control prevents the “clipFrom” value from being bigger than the “clipTo” value. However, if the
sampled spline is closed, the clip range can be looped, meaning that “clipFrom” can be bigger than “clipTo” and the
samples will be looped across the spline’s connected start and end.
Example in code:
6.1.4. Multithreaded
Enables multithreading for the Spline User’s calculations.
Note: For mesh generating Spline Users, only the vertex calculation operations are performed on the
separate thread – the information still needs to be written to the Mesh object in the main Unity thread.
27
Dreamteck Splines – User Manual
7. Tracing Splines
The Spline Tracers are a group of Spline Users,
meant specifically for positioning a single object along a
spline. This class of Spline Users fosters the Spline
Follower component which is one of the most commonly
used components when it comes to splines.
If “Use Triggers” is toggled, a Trigger Group field is shown. This is the trigger group that this tracer will be
using.
7.2. Direction
Defines the orientation of the object along the spline (Forward or Backward along the spline). In the case
of the Spline Follower component, the direction also defines the direction in which the follower will move.
28
Dreamteck Splines – User Manual
7.4. Motion
The motion module defines how the
transformation from evaluating the spline is
applied to the object. There are three axes for
each position, rotation, and scale. When an axis
is toggled, transformation will be applied along
it. The position and rotation components use
world axes while the scale axes are local to the
object.
It has two modes – 3D and 2D – which define how the rotation of the object will be applied. In 2D mode, the
provided settings are simplified.
Applying scale is disabled by default meaning that all axes are unchecked. When applying scale is enabled, an
additional “Base Scale” Vector3 field is presented. The base scale is the scale that is going to be applied to the
object. If the spline has various sizes, the base scale will be multiplied by the size value of the current spline
evaluation.
When toggled, Retain Local Rotation and Retain Local Position will attempt to preserve the last offset of the
spline tracer object in regard to the spline. These options accumulate an error over time.
29
Dreamteck Splines – User Manual
• Uniform
• Time
In Time mode, the “Follow Speed” field turns into the “Follow Duration” and the object moves along the
spline by incrementing / decrementing its current spline percent [0-1]. This means that for non-uniform
splines where points are closer or further apart, the object will follow with variable speed. The Time follow
mode, however, will make sure that the follower has finished following the spline in exactly the time I is
given to do so.
The “Follow” property defines whether or not the Spline Follower will be following the spline
automatically. If Follow is disabled, the follower can be caused to follow manually each frame by calling it’s
public method Move(float distance).
Three wrap modes control the Follower’s behavior when it reaches the end of a spline.:
• Default – when the end of the spline is reached, the follower will stop
• Loop – When the end of the spline is reached, the follower will start again from the beginning.
• PingPong – When the end of the spline is reached, the follower will change its direction
If “Face Direction” is toggled, the follower will face the direction of movement along the spline. If
unchecked, the follower will always face the forward direction even if it moves backwards.
30
Dreamteck Splines – User Manual
• Accurate
• Cached
By default, the mode is set to Cached which means that the cached samples of the spline will be used.
However, this in some cases results in jagged movement if the samples are not enough. This is why the
Accurate mode is also introduced. In Accurate mode, the projector re-calculates the spline path from scratch
using subdivision.
31
Dreamteck Splines – User Manual
Each MeshGenerator’s behavior is affected by the spline points’ colors and most of them are affected by the
points’ sizes.
32
Dreamteck Splines – User Manual
Setting this value to 0 will cause the Mesh Collider to update as soon as there is a change in the mesh. Note
that the Mesh Collider will not update if there aren’t changes in the mesh.
If multithreading is enabled, the mesh generation algorithm will be executed on another thread. However,
due to the thread-unsafe nature Unity’s API, mesh writing, collider updates and optimization are done on the
main thread.
Note: All mesh generators can generate a mesh with up to 64 000 vertices since this is the maximum
vertex count per mesh supported by Unity. If the vertex limit is exceeded for the generated mesh, an error
message will appear in the console and the mesh will stop updating.
Each channel has its own clip range which defines the spline region it is going to take up.
33
Dreamteck Splines – User Manual
When a mesh is added to a channel, it can be edited prior to the generation. This helps for correcting pivot
orientations, unwanted offsets or sizes. To configure a mesh, click on it in the Channel tab – it will open the
Configure mesh window:
It is also possible to use a custom handler function for controlling the offset, rotation and scale along the
extrusion. This can be used for some interesting effects and deformations (see API Reference).
Because of the triangular nature of the mesh, in some cases the texture coordinates of the Spline Renderer
might appear jagged.
This is most often observed when there are spline points with
different sizes and the solution to this is to add more edge loops. To do
so go to the inspector and increase the number of Slices:
This will reduce the jagged artefacts. The same applies for the
Path Generator component.
34
Dreamteck Splines – User Manual
Like the Spline Renderer, the Path Generator has the option for
multiple edge loops (called Slices) to prevent jagged texture
coordinates. However, the Path Generator’s slices also serve a
function of deforming the generated path. Turning on the “Use
Shape Curve” option will expose a curve editor. If the slices of the
Path Generator are set to a value bigger than 1, then the path can
be deformed using the curve editor.
• Flat
• Round
The Revolve property [0-360] controls the spin of the generated tube around
the spline. If less than 360, the Tube Generator will generate open geometry.
35
Dreamteck Splines – User Manual
If Extrude is different than zero, a secondary set of UV coordinates which control the side UVs will be
exposed in the inspector.
Surfaces can also be extruded along another spline. Drag the SplineComputer component of the extrusion
spline in the “Extrude Path” field in the Inspector:
36
Dreamteck Splines – User Manual
The Bake Mesh window provides a range of settings for baking and a Bake button.
37
Dreamteck Splines – User Manual
9. Particle Controller
The Particle Controller uses a Shuriken particle system and places its particles along a spline.
This component offers a preview right in the editor if it’s attached to the particle system that it controls.
The Particle Controller has an Emit point which controls where new particles will be spawned. The modes
are:
Another very important option of the Particle Controller is the Motion type. This controls the particle behavior
over its lifetime. The available motion types are:
38
Dreamteck Splines – User Manual
The Object Controller has two Object Methods which define how the objects it controls are created.
If Delayed spawn is turned on, the objects will spawn over a certain period of time. This is mostly used to
prevent spike lags caused by spawning many objects at once. Delayed spawn does not work in the editor.
In Get Children mode, the child objects of the Object Controller’s Transform will be used. Adding or
removing objects from the hierarchy will include or exclude them from the controller.
Custom rules can be assigned to the offset, the rotation or the scale property of the Object Controller.
Once a custom rule is assigned, the inspector GUI for the given section will be replaced by the GUI of the
custom rule and the Object Controller will immediately start to draw the placement, rotation or scaling logic
from the rule.
39
Dreamteck Splines – User Manual
Note: Editing the values of the custom rule from the Object Controller’s inspector will change the values inside
the custom rule object. If multiple object controllers require different values, separate rule objects need to be
created. To make sure rule object values are saved, the project needs to be saved (File/Save Project).
More custom rules can be easily created by inheriting the ObjectControllerCustomRuleBase and overriding the
methods. The ObjectControllerSineRule and ObjectControllerSpiralRule can be used as a reference. When creating
new rules, use the MenuItem attribute to make the scriptable object available through the Create menu.
40
Dreamteck Splines – User Manual
• Growing: will invoke the event when the target length has been reached by growing
• Shrinking: will invoke the event when the target length has been reached by shrinking
• Both: will invoke the event when this value has been reached or passed in both directions
This component has one additional module that controls its behavior. Refer to Triggers and Modules for
more information.
When an Object Bender is added in the editor or in runtime, it will be in edit mode by default. This
means that the object bender will not work. The edit mode allows the developer to edit the children in the
hierarchy.
In edit mode, the ObjectBender
editor will visualize the bounds of the
parent object and all of the children in the
hierarchy. These bounds include the
Transform components, meshes, colliders
and SplineComputers.
When in edit mode, there is a
“Bend” button at the bottom of the
ObjectBender’s inspector. Clicking it will
exit edit mode and will start bending the
objects along the spline.
41
Dreamteck Splines – User Manual
13. 2D Collision
Dreamteck Splines has means of generating 2D colliders.
• Path: creates a path along the spline, much like the Path Generator
• Surface: creates a solid shape, much like the surface generator
42
Dreamteck Splines – User Manual
Note: The edge collider will be generated at the position of the spline and therefore the spline rendering will
cover the collider visualization making it seem like nothing is happening.
43
Dreamteck Splines – User Manual
Currently, triggers are supported only by the Spline Tracer components (Follower, Positioner and Projector)
but trigger-checking functionality can be easily implemented by calling SplineComputer.CheckTriggers and
providing the start percent along the spline and the end percent. If there are any triggers that fall between these
two values, they will get invoked.
After a group is created, triggers can be added inside it by pressing the “Add Trigger” button.
When a trigger is created, it is added to the trigger list under the trigger group. Clicking on the trigger’s
name will open the trigger’s panel:
The On Cross event is the event that gets fired when the trigger is crossed.
44
Dreamteck Splines – User Manual
Dragging the trigger handles along the spline in the scene view will set their position.
Triggers and trigger groups can be renamed and deleted by right clicking on their names in the inspector
and choosing the corresponding option.
Currently, Spline Tracers can use only one trigger group but in future updates using multiple groups will be
added.
From here, all triggers from all trigger groups can be checked like this:
spline.CheckTriggers(0.0, 0.5);
This will invoke all triggers which are in the range [0-0.5] and their type is set to either Forward or
Double. To check triggers of type Backward, switch the position of the values:
spline.CheckTriggers(0.5, 0.0);
If there are triggers, set to work once, they can be reset by calling:
spline.ResetTriggers();
45
Dreamteck Splines – User Manual
To check and reset triggers only from a given trigger group, the “triggerGroups” array needs to be
used:
spline.triggerGroups[0].Check(0.0, 0.5);
spline.triggerGroups[0].Reset();
This will check and reset all triggers in group 0.
Individual triggers can also be changed through code by modifying the same properties, exposed in
the inspector:
spline.triggerGroups[0].triggers[0].name = "Explosion";
spline.triggerGroups[0].triggers[0].position = 0.75;
All modifiers work in the same way – they just modify different values of the spline samples. When a
modifier foldout is expanded, there are always these UI elements:
• Draw All Modules – will draw all modules from the given group in the scene view regardless of
whether they are selected.
• Blend – a general multiplier that applies to all modules under the given group. Moving the value
towards zero will decrease the effect of all modules in the group.
• Add New ### - The “Add New” button will add a new module inside the given group.
When a module is selected, it is drawn in the scene view and int can be edited there directly. The two bigger
handles define the range where this modifier works. The smaller handles define the area of full strength
(between the small handles).
Pressing Ctrl will display an additional handle in the middle which when dragged, moved all handles together
along the spline.
46
Dreamteck Splines – User Manual
The offset is defined by either directly dragging the offset handle in the scene (the small circle) or
through the inspector’s offset property.
The rotation offset vector is local to the spline and can be edited either by using the rotation handle in
the scene or by modifying the rotation field of the
modifier inside the inspector.
47
Dreamteck Splines – User Manual
There are four blending modes that can be used for this operation:
• Lerp
• Multiply
• Add
• Subtract
48
Dreamteck Splines – User Manual
The first morph channel is the base channel and holds the original spline shape. Each channel that is added
afterwards will have a blend slider which controls how much the shape in this channel is morphed towards.
After this, re-arrange the points of the spline and click the Create channel button again. A new morph
channel will be created that holds the new shape.
With that new channel created, the two shapes can now be blended between by pulling the slider of the
second channel left and right.
Each channel can interpolate the spline points linearly or spherically – this is set using the Interpolation
property. The curve property controls the blend interpolation rate.
To edit a channel’s points, edit the spline points and click the channel record button:
49
Dreamteck Splines – User Manual
• Cycle wrap
• Update Mode
• Cycle Duration
Update mode defines the update cycle in which the logic will be performed – Update, LateUpdate or
FixedUpdate
50
Dreamteck Splines – User Manual
17. Nodes
Nodes are a key feature and serve two very important purposes - to bind points of Spline Computers to
other scene objects and to create junctions.
To create a Node, go to GameObject/3D Object/Spline Node. This will create a new Game Object with a
Node component in the scene.
Another way to create a Node is just by adding a Node component to an existing object.
The Node will now require a point from the Spline Computer to be selected. To select a point either select it
from the dropdown menu and click “Link” or click on a point in the scene view. If the point has no
connections added, after the first point is selected, a dialog will appear asking what to do when connecting:
• Snap and Align – Will move the Node to the selected point and will rotate the node along the spline
• Snap – Will just move the node to the selected point’s position
• No – Will move the selected point to the node
51
Dreamteck Splines – User Manual
After the node has been connected, its Transform can then be animated or a Rigidbody can be attached and
when the Node moves, the connected point will also be updated.
A Node can have more than one Spline Computer connected to it. Repeat the procedure with another Spline
Computer to add a new connection.
When editing a point that is connected to a Node in the Spline Editor, the node’s position will also be
updated and therefore all the other Spline Computers connected to it.
If the connected spline is of Bezier type, a “Swap Tangents” button will be available next to the spline’s entry
in the connections list. Pressing it will change the direction of the connected point’s tangents.
To remove a spline connection, click on the “x” button inside the connections list panel.
Clicking the “Select” button will select the connected spline’s Game Object in the scene.
• Transform Normals – Should point normals be transformed when the Node rotates?
• Transform Size – should point sizes be transformed when the Node is scaled?
• Transform Tangents – should Bezier tangents be transformed by the Node’s rotation?
• Node Type – Smooth will apply the same point properties to all connected points (size, color,
normals, tangents) so that all points, connected to the Node are the same. Free will preserve the
points’ properties and only sync position.
52
Dreamteck Splines – User Manual
17.2. Junctions
When two Spline Computers are connected to the same Node, this is considered a junction since getting
the connection list of a Node provides all the information, needed to know in order to switch to another
spline.
Junctions are used entirely through code. The Spline Tracer components provide a convenient API for
handling junctions.
This example script can be attached to either a Spline Positioner, Follower or a Projector and will work
for bopth of them:
using System.Collections.Generic;
using UnityEngine;
using Dreamteck.Splines;
53
Dreamteck Splines – User Manual
}
}
If it seems very complicated, here are simplified versions of both the OnNode and SwitchSpline methods:
Junction picking can be aided with additional, custom components. For example, an additional
component that is attached to the Node object which says which connections can be used. An example for
this can be found inside the Train example scene. There, a component called “Junction Switch” is used to do
exactly this and the logic for junction picking and switching can be found inside TrainEngine.cs where inside
OnNode, a reference to the JunctionSwitch is used in order to pick the right connections.
To fix this issue, make sure that all Spline Computers inside any prefab are set to rebuild on awake.
55
Dreamteck Splines – User Manual
If this warning appears, go to the scene’s hierarchy, select a Spline Computer and click on the tools window
again. This will update it and the warning will disappear.
56
Dreamteck Splines – User Manual
For the Level Terrain tool to work, the scene needs to have at least one terrain and a Spline Computer
needs to be selected. If the scene has more than one terrain, the terrain that should be leveled should also
be selected along with the Spline Computer.
Once open, the Level Terrain tool will display a preview of the terrain’s heightmap, the path heightmap
which will be black and a preview of the brush feather.
To level the terrain using the selected spline(s), click the “Level” button. The path heightmap will be
drawn and the terrain will be sculpted.
57
Dreamteck Splines – User Manual
An “Apply” and “Revert” buttons will appear under the heightmap previews. If the result is not
satisfying, edit the spline and the settings and click Level again – the previous level will get replaced with the
new one. To save the terrain, click “Apply” – this will write the level data to the terrain permanently.
19.3. Import/Export
Splines can be imported and exported from and to other software using the Import/Export tool. The
currently supported formats are SVG and CSV datasets.
19.3.1. Importing
To import an SVG or a CSV file click the “Import” button. This will open a new file browser. Navigating to
the desired SVG or CSV file and clicking “Open” will instantly import the splines from the file in the Unity
scene.
NOTE: Splines from SVG files are usually very big, about the size of a Canvas or even bigger. If the
imported SVG spline isn’t visible after import, make sure to zoom-out further in the scene.
After the spline has been imported, a new object with the name of the file will be created in the scene
and the import tool’s panel will display some importing options:
• Scale Factor – This is the scale factor of the imported graphic. A scale factor of 1 will retain the size
of the graphic.
• Facing axis – The orientation of the imported graphic. By default it is Z which means no rotation
• Always draw – Should the splines be drawn in the scene constantly after closing the import tool?
58
Dreamteck Splines – User Manual
19.3.2. Exporting
To export one or more splines, the splines first have to be selected in the scene. If no splines are selected
in the scene, the export button will be unavailable.
When the export mode is toggled, a Format dropdown menu will be available, allowing the user to select
between SVG and CSV.
The projection axis dropdown menu defines the axis along which the spline will be flattened and
projected onto the SVG canvas.
The Dataset columns field allows for customization of the columns that will be written in the CSV file. For
example, if only the points’ positions are needed, all columns except the position column should be
removed.
CSV Export also supports flattening. If “Flat” is toggled, a projection axis dropdown menu is presented.
59
Dreamteck Splines – User Manual
Once a reference to the given component is obtained, all properties exposed in the editor are available
in code. For example, here is how getting a reference to a SplineFollower and setting its follow speed looks
like:
In order to change the spline used by the current user, set the user’s “spline” property to the desired
spline:
Setting the spline through code like that will immediately tell the user to move all of its functionality
over to the new spline.
60
Dreamteck Splines – User Manual
int pointToRemove = 2;
SplineComputer spline = gameObject.GetComponent<SplineComputer>();
SplinePoint[] points = spline.GetPoints();
SplinePoint[] newPoints = new SplinePoint[points.Length - 1];
for (int i = 0; i < points.Length; i++)
{
if (i < pointToRemove) newPoints[i] = points[i];
else if (i > pointToRemove) newPoints[i - 1] = points[i];
}
spline.SetPoints(newPoints);
Evaluate requires a SplineSample object to be created and passed to it in order to work. It is usually a
good practice to define the SplineSample in the initial variables and re-use in order to reduce GC. However,
in this example, the SplineSample is defined just before Evaluate is called so that it can work when copied.
Note that the Evaluate methods use parameters of type double and not float so when hardcoding
percentages, do not add the “f” behind the number. For example spline.Evaluate(0.5f, sample) is wrong.
Both methods also have an override where instead of a double percent (0.5 for example), an integer
value defining a point index can be provided and this will return the evaluation at the position of that control
61
Dreamteck Splines – User Manual
To find the percent of a spline that corresponds to a certain distance in world units along it, the Travel
method can be used.
With all that said, here is an example of how to find the true percent that lies in the physical middle of
the spline:
For example, in order to get the percentage of a Spline Follower along a spline, it can be done like this:
An empty SplineUser example is provided in the Components folder. It can be used as a template for
creating new custom ones.
SplineUser classes are not supposed to have Update, FixedUpdate and LateUpdate methods. They can
have a Start method and an Awake method through overriding however:
62
Dreamteck Splines – User Manual
In order to access the generated spline samples inside the custom SplineUser class the protected
property “sampleCount” should be used to determine the count of the spline samples and then the
GetSample(int index) method to get the sample at any given index. Note that these are the samples within
the clip range of the Spline User and changing the clipFrom or clipTo properties will also change the
sampleCount and the returned samples by GetSample.
The Build method can either run on the main thread or if Multithreading is enabled, it can run on a
worker thread and therefore it is important to only have thread-safe code inside. For example, if the spline
user generates a mesh, all vertex calculations should happen inside the Build method, using sampleCount
and GetSample(), and all mesh operations like setting the vertices for the mesh should happen in PostBuild.
Here is an example of a simple custom SplineUser which draws all spline samples within its clip
range:
Look at how existing SplineUser classes are implemented in order to get a better understanding of how
SplineUser inheritance works.
63
Dreamteck Splines – User Manual
20.6.5. Rebuilding
The SplineUser class has the Rebuild(bool sampleComputer) method which forces the user to recalculate
on the next update cycle.
SplineUsers rebuild automatically when their spline is modified or their properties are changed. That
however does not happen when the properties of custom SplineUser classes are modified. In order to make
the SplineUser class rebuild, custom setters should be implemented that call the Rebuild method.
Example:
private bool _state = false;
public bool state
{
get { return _state; }
set
{
if (value != _state) //Only rebuild if the value is different
{
_state = value;
Rebuild(); //Rebuild but don’t resample the spline
}
}
}
Rebuild is a public method so it can also be called from another object. Rebuilding happens once per update
cycle no matter how many times it’s called prior to that.
20.6.6. RebuildImmediate
Rebuild waits for the next update cycle so calling it will not yield any changes immediately. In some
cases, rebuilding should happen instantly and that’s what RebuildImmediate is for. It calls the rebuild
sequence regardless of update cycles and will yield results immediately.
Calling RebuildImmediate multiple times per update cycle will cause the SplineUser to rebuild as many
times as RebuildImmediate is called.
After the initial caching calculation, no other calculations will be performed unless the spline is changed.
The computational complexity and scale depend greatly on the spline settings. For example, if the
Sample Mode of the spline is set to Default, moving a single spline point through code or inside the editor
will only update the spline’s samples around that point and will not recalculate the entire spline. However, if
the Sample Mode is set to Uniform or Optimized, the entire spline will be re-calculated.
For splines, set to Local space, an additional Transform operation is run after the spline samples are
calculated. If the Spline Computer’s Transform is changed, the Transform operation will run on all samples
but the spline calculation will not be performed. This is different from the legacy Dreamteck Splines (version
1.1) where both the sample calculation and the transform are performed regardless of what is happening.
Having many static Spline Computers in the scene costs nothing but memory since nothing is updated
until it needs to update. Even if a lot of Spline Users are attached to the splines, no spline calculation
operations will be performed as long as the spline objects are not changed.
Similar to the Spline Computer, most Spline Users do not perform operations when not needed. For
example, all Mesh Generators with the exception of the Spline Renderer, perform the mesh generation
operation only when the spline changes or some property of the generators themselves is changed.
For the Spline Follower – the follow logic runs every frame on the cached spline and so many followers
can be added to the same scene without performance drop. On mobile this number varies between 50 and
200 running simultaneously. However, if that many objects need to follow a single spline, consider using an
Object Controller instead as it is meant exactly for this – to position lots of object on a spline and
incrementing the “Evaluate Offset” property could give a similar result.
The Particle Controller runs every frame and for every particle but it is still pretty speedy and suitable for
mobile.
Probably the most taxing Spline User is the Spline Renderer component as it runs once for each camera,
every frame. If the game has many cameras running simultaneously or there are many/big splines in the
scene, using a Spline Renderer, the framerate could drop fast. Always consider using the Path Generator
component first before jumping onto the Spline Renderer, especially for 2D games. 2D games cannot benefit
65
Dreamteck Splines – User Manual
from the Spline Renderer at all – there will not be any visual difference between using a Spline Renderer and
a Path Generator in a 2D game.
The best way to optimize would be to disable all Spline Computer components. This will not disable the
splines but will disable the checks every frame. Then whenever a spline needs updating, either enable while
its needed or call ResampleTransform() on it.
21.4. What happens when a scene, full of SplineComputers and SplineUsers loads?
Spline Computers and Users cache their values into the memory and everything gets serialized into the
scene. By default, when a scene loads, all values will be de-serialized and no calculations will be performed.
However, if a Spline Computer is set to rebuild on Awake (by toggling “Rebuild On Awake “in the
inspector), as soon as the Spline becomes active, it will be re-calculated and all connected Spline Users will
run their update logic.
• Evaluate – Evaluate the spline at a given percent [0-1] and return an entire object with values like
position, direction, color, size, etc.
• EvaluatePosition – Evaluate the spline at a given percent [0-1] and return just a Vector3 object for the
position
• Travel – Move along a spline in world units starting at a given percent. The returned result is a new
percent that can be used to Evaluate the spline.
• CalculateLength – Calculates the distance in world units along the spline between two percentages
• Project – Returns the spline percent [0-1] that is closest to a given point in world space
They al can be found in the Spline class, as well as in SplineComputer, SplineUser and SampleCollection.
66
Dreamteck Splines – User Manual
When calling the methods on a SampleCollection object, they get performed on the cached samples and
no spline calculation operations are run.
However, there is more to that. The SplineComputer versions of the methods all have an additional,
optional parameter called “mode”. If the mode parameter is passed as
SplineComputer.EvaluateMode.Calculate, then the spline will be calculated and the spline result will be
transformed on the spot. This costs more performance but if pinpoint accuracy is needed, it can be very
useful.
For example, if the clip range is set to [0.0 – 0.5], calling EvaluatePosition(1.0) on the Spline User will
return the position at 0.5.
This also applies for the returned percent for Travel and Project.
67
Dreamteck Splines – User Manual
22.4. How to distribute objects evenly along a spline using the Object Controller?
The default behavior of all splines is such that they stretch and squash when control points are further
apart or closer together (refer to Sample Mode for a better explanation). To mitigate this effect, either make
sure to place all control points at even distances (see Distribute Evenly) or use a Uniform sample mode for
the Spline Computer.
22.8. I'm using the Spline Mesh component and the extruded mesh does not
perfectly follow the spline or is too edgy. What is going on?
The Spline Mesh component extrudes the provided meshes along the spline without creating
additional geometry. This means that if you are trying to extrude a single cube mesh along a spline, the start
and end vertices will simply stretch at the both ends of the spline because there are no vertices in the middle
which can be positioned along the spline:
68
Dreamteck Splines – User Manual
No matter how smooth the spline is, if the mesh does not have enough detail, it will be jaggy.
To fix this, either increase the repetition count of the mesh in the channel or if this isn’t an option,
add more vertices in between the two ends of the mesh in the modeling program.
22.9. I’m using a mesh generator to generate a big mesh but the mesh does not
generate. What is going on?
Unity has a limit of 64,000 vertices per mesh object. If the mesh exceeds this limit, it cannot exist
and therefore the mesh generators will stop updating the geometry.
In such cases, consider splitting the geometry into two separate objects. Create two game objects
and add the same Mesh generator component to both. Have both use the same spline and set the clip
range of the first Mesh Generator to [0-0.5] and the clip range of the second Mesh Generator to [0.5-1].
22.10. How can I change the speed of the Spline Follower component during
runtime?
SplineFollower follower = GetComponent<SplineFollower>();
follower.followSpeed = 10f;
22.11. No matter where I instantiate a Spline Computer, the spline appears always
in the same place. What is happening?
Double check if the Spline Computer’s space is not set to World instead of Local and make sure the
Spline Computer is set to rebuild on awake from the Spline Computer panel.
69
Dreamteck Splines – User Manual
23.1. SplinePoint
A spline control point used by the Spline class.
23.1.1. Enums
• SmoothMirrored – Mirrors both tangents
• Broken – Each tangent moves independently
Type { SmoothMirrored, Broken, SmoothFree };
• SmoothFree – Tangent direction is mirrored
but length is independent
bool AreDifferent(ref SplinePoint a, ref SplinePoint b) Returns true if any of the points’ values are different
70
Dreamteck Splines – User Manual
23.2. SplineSample
71
Dreamteck Splines – User Manual
23.3. Spline
23.3.1. Enums
Direction { Forward = 1, Backward = -1 } Traversing direction of the spline.
Type of the spline as described in the
Type { Hermite, BSpline, Bezier, Linear };
documentation
72
Dreamteck Splines – User Manual
73
Dreamteck Splines – User Manual
23.4. SampleCollection
23.4.1. Public Properties
SplineSample[] samples The array of spline samples this collection holds
The sample mode these samples have been
SplineComputer.SampleMode sampleMode
calculated with
int Count The count of the samples
double clipFrom = 0.0 The start region the samples are clipped from
double clipTo = 0.0 The end region the samples are clipped to
74
Dreamteck Splines – User Manual
double Travel(double start, float distance, Spline.Direction Moves along a sample collection using
direction = Spline.Direction.Forward) world units and returns the new percent
Finds the closest point along the collection
void Project(Vector3 position, int controlPointCount,
to a world point and returns its percent
SplineSample result, double from = 0.0, double to = 1.0)
value
Calculates the length in world units
float CalculateLength(double from = 0.0, double to = 1.0)
between two points along the spline
75
Dreamteck Splines – User Manual
23.5. SplineComputer
23.5.1. Enums
• World space does not take the
Spline’s transform into account
Space { World, Local };
• Local transforms the spline using
the transform
• Cached uses the cached spline
samples to operate
EvaluateMode { Cached, Calculate } • Calculate recalculates the spline for
better precision at the cost of
performance
Sample mode as described in the
SampleMode { Default, Uniform, Optimized }
documentation
Which update method should the Spline
UpdateMode { Update, FixedUpdate, LateUpdate, AllUpdate, Computer use? None does not update the
None } spline and waits for manual update using
the Rebuild method
76
Dreamteck Splines – User Manual
spline point
80
Dreamteck Splines – User Manual
23.6. SplineUser
23.6.1. Enums
UpdateMethod { Update, FixedUpdate, LateUpdate }
81
Dreamteck Splines – User Manual
82
Dreamteck Splines – User Manual
23.7.1. Enums
Denotes an approach to the motion application of the
tracer. Transform will use the position and rotation of
PhysicsMode { Transform, Rigidbody, Rigidbody2D } the Transform component. Rigidbody will use
MovePosition and MoveRotation of the Rigidbody
component. Rigidbody2D will use a 2D rigidbody.
23.7.3. Events
Called when the tracer passes a node or multiple
JunctionHandler onNode nodes. Returns the list of passed nodes in the last
frame.
Called when the TransformModule applies the
EmptySplineHandler onMotionApplied motion – useful to apply additional offsets via script
directly to the tracer’s transform or rigidbody.
83
Dreamteck Splines – User Manual
23.8. TransformModule
Used by the SplineTracer to apply transformation
84
Dreamteck Splines – User Manual
23.9. SplineTrigger
23.9.1. Enums
• Double works both forwards and
backwards
Type { Double, Forward, Backward }
• Forward only works forwards
• Backward only works backwards
85
Dreamteck Splines – User Manual
23.10. SplineTriggerGroup
86