Notifications
Article
2D IK, 2D Animation & Spriteshape generator
Updated 9 months ago
350
0
2D IK, 2D Animation, Cinemachine & Runtime Spriteshape generator
Wishing I had noticed this contest sooner, I just learned of these awesome new 2D Unity tools the other day.
It is down to the wire with 4 minutes left, but In that little time I learned a lot about using these and I created this sample of generating the new spriteshapes at runtime.
You can also draw the terrain on with the mouse or touch.

I will add more cool stuff to these spriteshape gen tools along with some other use cases and put it on the store for everyone.

The generator above will follow a gameobject position and insert new points into the original Spriteshape allowing for a endless terrain. I added a slider to show increasing or decreasing the slopes at runtime. The terrain will also update the changes in the collider as it creates them.
Here is some of the code behind for adjusting the shape at runtime.
//generate only when less than Maximum Points in spline while (spline.GetPointCount() < MaxPoints) { if ((spline.GetPosition(0).x) < Player.transform.position.x - 23) spline.RemovePointAt(0); xPos += DistanceToNextInsert; DrawTargetToFollow.transform.position = new Vector3(xPos, yPos, transform.position.z); var insertPoint = DrawTargetToFollow.transform.position; spline = spriteShapeController.spline; spline.InsertPointAt(spline.GetPointCount(), insertPoint); var insertPointIndex = spline.GetPointCount() - 1; spline.SetTangentMode(insertPointIndex, ShapeTangentMode.Continuous); spline.SetHeight(insertPointIndex, 1); //ToDo: setup additional Heights LastPoint = insertPoint; spriteShapeController.BakeCollider(); yield return new WaitForSeconds(.21f); }
Here is a quick video showing generating the spriteshapes by drawing on the screen using mouse or touch.
A few pics of the creative process.
Thanks for checking out my submission. There was many other submissions that looked great and were full of talent. Some must have taken a good amount of time to achieve.
I think that is the greatest part about developing in unity is always learning some new ways to do things as new tools are introduced into the engine.
I also believe my submission showcased how one can learn the new tools and provide a nice example of using them to get a new concept game going very quickly.
I will build on what I have learned and create a nice asset that everyone can use to further unlock the potential of these 2D tools.
Justin Markwell
Software Engineer - Owner
9
Comments