Transplanter

The latest Rapid Prototype Production project, Transplanter, was made in two weeks by our team of five. The game is playable from Itch here:

https://topromen.itch.io/transplanter

I already shared a development story yesterday about an interaction between Unity’s sprite renderer and animators, which I shared here (The trouble with changing color on an animated object). I’m going to share a little bit of my development before that here.

In large part, I worked on a waypoint system for all the little sprites moving around on screen – a waypoint system that I used some lessons I learned from my previous work on Onyx Crown and used to make the system easier to use for my designers. One of the big pitfalls with my previous system was how easy it was to forget a waypoint, plug the wrong ones into each other, and not know what was wrong. It was also time consuming. My efforts to alleviate those pains didn’t quite pan out, so it was back to the drawing board.

This time, had the waypoints update each other, in editor, using Unity’s ‘OnValidate()” function. In this way, waypoints were able to update each other automatically, making working with them more intuitive, and significantly easier on our level designer. Fully half of my script is stuff like this – things that I built to make using my script easier for the designers to use (mostly from GUI Gizmo draws, which will not show up in builds). Below is a snippet of just the validate code:

private void OnValidate()
    {
        numberOfWaypoints = 0;

        if (downWaypoint != null)
        {
            numberOfWaypoints++;
            WaypointScript otherScript = downWaypoint.GetComponent<WaypointScript>();
            if (otherScript == null)
                print("Error! " + downWaypoint.name + " does not have a waypoint script attached!");

            else if (otherScript.waypointType == waypointType || (otherScript.waypointType != WaypointType.MainWaypoint && waypointType != WaypointType.MainWaypoint))
            {
                otherScript.upWaypoint = this.gameObject;
            }
        }
        if (upWaypoint != null)
        {
            numberOfWaypoints++;
            WaypointScript otherScript = upWaypoint.GetComponent<WaypointScript>();
            if (otherScript == null)
                print("Error! " + upWaypoint.name + " does not have a waypoint script attached!");

            else if (otherScript.waypointType == waypointType || (otherScript.waypointType != WaypointType.MainWaypoint && waypointType != WaypointType.MainWaypoint))
            {
                otherScript.downWaypoint = this.gameObject;
            }                            
        }
        if (leftWaypoint != null)
        {
            numberOfWaypoints++;
            WaypointScript otherScript = leftWaypoint.GetComponent<WaypointScript>();
            if (otherScript == null)
                print("Error! " + leftWaypoint.name + " does not have a waypoint script attached!");

            else if (otherScript.waypointType == waypointType || (otherScript.waypointType != WaypointType.MainWaypoint && waypointType != WaypointType.MainWaypoint))
            {
                otherScript.rightWaypoint = this.gameObject;
            }                              
        }
        if (rightWaypoint != null)
        {
            numberOfWaypoints++;
            WaypointScript otherScript = rightWaypoint.GetComponent<WaypointScript>();
            if (otherScript == null)
                print("Error! " + rightWaypoint.name + " does not have a waypoint script attached!");

            else if (otherScript.waypointType == waypointType || (otherScript.waypointType != WaypointType.MainWaypoint && waypointType != WaypointType.MainWaypoint))
            {
                otherScript.leftWaypoint = this.gameObject;                   
            }                      
        }
    }

I also spent a lot of time trying to get the way the characters on screen move along the waypoints to look and feel more organic, and natural. As such, waypoints are programmed to not just work like a single point, but rather a random range of points from a singular central point, that actors would then use.

From there, it’s just about how I pass this information between entities – from waypoints, to actors. The actors themselves have a number of checks they do, that mostly boil down to making sure they don’t walk back the way they just came, and don’t walk along building spawner waypoints (unless they have to).

This was a massively fun project, and I am very pleased with the result.

Leave a comment

Design a site like this with WordPress.com
Get started