Bezier Spline tool!

Here is where I found the tutorial to help me make this

Here is the repo link containing the Unity Package

This is what I learned while making it
First of all, I need to thank  Shaun Allen for helping me with figuring out how to export a package in unity, all you have to do is download a single file and import it in Unity, exporting has an automatic dependencies option, so you just select the main scripts and/or prefabs you want and it also selects anything else it requires to run. It’s good practice to remove anything that is not critical and include instructions on how to use the tool, especially a video tutorial. You should bury anything that isn’t used directly by the user, and ensure you set up useful folders and names. Also, comment your code! If something doesn’t work, or someone needs to change the scripts to do what they want, you can save a lot of time through commenting what everything does, what it talks to and why, and this will also help people learn how to set this sort of thing up themselves. I haven’t set up any comments in this myself, as this is the first time I have created a tool and the script itself is fairly complex, I still need to work through everything to fully understand the inner workings, so keep an eye out here for an updated version in the future.

In doing this, I learned a few things about creating tools in unity, like GUI functions and how to create an editor panel. Enabling the use of ctrl+z, and getting unity to ask if you want to save your changes when you try to close it after making changes to the spline. I even tested creating my own contextual buttons, which worked but had trouble with the script itself (I was trying to insert points to the middle of the array of points, but there are a few arrays that stopped functioning correctly, this is why I need to work through it again)
I was also made aware of other types of curves available other than bezier. The problem with a bezier curve is that to shape the curve, you need to pull its point around a lot further out than the curve sits, the problem here is that the curve never intersects a point, and is, therefore, difficult for a person to use.
The scenario would be that the curve is being used as a path for a camera, which needs to hit a very specific point or even several. On a Catmull curve, for example, the curve intersects each point which are what gets placed by the user. This is very precise, and the tool I created also does this (as this is a spline, every 4th points is intersected by the line, with the two points in between controlling the curve of the path). To control the curve, there are two ‘rotation’ handles surrounding the main handle, this is what controls the angle of the curve and speed of movement along the path.
Here is the maths behind a bezier curve. We should be using a simplified version of the cubic bezier curve.

Things I learned from playtesting the tool
The tool controls are fiddly. If you click off it, it deselects, which is some bad ‘player feedback’, and is too easy for this to happen as the handles on the tool are very small.
The handles need to have an adjustable size, this way people can decide what works best for them, as if it is too big, it will obscure too much of the scene it is in.
Its a little hard to know how to use the tool right from the get go, as it requires several scripts on separate game objects. this is mainly run through in the instructions, but thats also a wall of text, no one reads instructions anymore. A good way to fix this is to create a prefab on the top level of the hierarchy, to easily pull into the scene a working example of its functions, a demo scene of all the cool things it can do, and a tutorial video running through the correct set up of this scene.

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s