Completion Detection System for Unique Tasks


One of the core components of Not so Trash Panda is the completion of various tasks. With there being several tasks with different requirements, this meant that having one single script for them to work off was not going to work. Due to this, I had to start using Baseclass scripts, something that (at the time) I was not comfortable doing. 

Baseclass Scripts

For the uninitiated, Baseclass scripts allow you to make several different scripts that a sort of branches from a single core script. This was especially useful here since I was able to make a baceclass for task detection. This baseclass contains variables for interacting with a UI component that functions as a task list. There is also a method that is called when a task is completed, and this will be called in the various scripts that derive from this baseclass. This script also contains a method called EffectsInWorld, which can be overridden to have an effect in the game, such as placing an object down.

Example of Inherited Script

An example of one of these scripts is TaskDetectionMulti, which is used for a task that requires multiple objects to be placed into a detector zone. This script uses a gameobject array variable for the objects that are associated with the task, as well as a boolean array that associates with each object in the previously mentioned array. This boolean is turned on depending on the object that was placed in the detector zone. Once all of the objects are placed in the zone, the task will be marked as completed.

Using Inherited Scripts as Baseclass

For another example of using baseclass scripts, I had to make an inherited script into a baseclass when making the doghouse task detector script. In this case, the doghouse script inherits off of the TaskDetectionSingle script, which inherits off of the BaseClassTaskDetection. The doghouse script is different from the TaskDetectionSingle in the sense that it removes the zone that prevents you from moving forward. For the sake of visualization, I made the blocking zone a transparent blue to see how the task works.


All of that said, the point is that this task detection system would be much more frustrating not only to program, but also to set up in the editor. Being able to use Baseclass scripts has been a lifesaver during this task (haha), and I am very grateful for being able to use them.

Get Not so Trash Panda

Leave a comment

Log in with itch.io to leave a comment.