Spline Level Editor

Inspiration

Hi, I recently found this video about how some of the things worked when Rayman Legends was made and I thought that the way they could bend and form their platforms when creating levels looked really useful.

I wanted to try doing something similar just for fun and I had never worked with programming meshes before and thought it could be useful in the future.


My version

I used Unity for creating my spline thing, mostly because I also want to learn more about unity and it seemed like the easiest approach.

The main goal I had was to create a mesh generated from certain points in the x and y axis that curved smoothly to create rounded corners between the lines formed by the points.

I started with creating points represented by a 2d vector array and tried to find the points in between these vectors to create more points that would form a sort of a rounded motion. I ended up with this result.


I created options for how detailed the roundness of the curves should be and also how wide they should be, right now these settings is for all points, but I may in the future make so these settings could be different for different points.

After I got this information about all the points I could start creating the mesh out of that information. I was surprised of how well it worked to create a mesh generated by script. I thought it would be a lot harder task but it went really smoothly.
I started by calculating the vector pointing outward from each point depending on the vectors direction that could be created from the points after and before the current point. Then it was just to create all points for the meshes.

I also wanted the texture that would be applied to the mesh to tile correctly. So I had to calculate the UV maps from the previous point to the current point. This is the result of the mesh created from this.


Next step

I would like to create this in the z-axis as well to see if that would be something I could manage to do. It could be useful for creating tunnels or pipes fast In an level editor. I also want to try making this more like a plugin with its own unity window and drag able points in the editor view. Right now the points are just controlled as a public Vector2d array. It would also be really useful to create like a button that would save your created mesh in the asset folder.

Summary

This was a real fun project to work with But I have only had the time to work with this for one evening. I hope I would be able to get some more spare time over so that I could continue to make the improvements I have planed for it. I also think I learned pretty much by doing this project.