Using empty game objects as target points.


In Not so Trash Panda, there are several things you are able to climb, such as the lattice on a few of the houses or a drainpipe that will fall when reaching the top. This climbing system has gone over quite a few changes over the development of this game, so I am going to go over some of these iterations and how I came to the currently used system. 

The original climbing system

When originally creating the climbing system. I made a prefab that uses four game objects. One of which is the box the player will collide with to initiate the climb, and the other three being empty objects that function as target locations. 

Each of the empty game objects have functions as stated below:

  • The orange circle at the bottom (LookTarget) is used to align the player model to look in that direction when starting the climb to ensure the animation looks correct.
  • The yellow diamond at the top (TopOfClimb) is the target location that the player will move toward when the climb is started. It also functions as an endpoint of the climb itself.
  • The Yellow circle at the top (ClimbEndpoint) is used as a correctional location to teleport the player to once they have reached TopOfClimb. This is to make sure that the player reaches their intended destination.

With this original system came a few problems. The most noticeable problem being that the width of this climbable object did not match the lattices very well so I had three of these individual objects right next to each other. This would function mostly as you would expect, but occasionally the player would collide with two at once and end up climbing at super speed. 

The Solution to a silly problem

For a while I had left this system the way it was, but I knew it was flawed. My solution came to me when I was figuring out a good way to move the player away from the doghouse after the player got too close. I ended up drawing some similar code from the climbing system, but it needed a change in order to send the player to several different locations depending on where the player collided with the doghouse.

As you can see here, I ended up having a bunch of potential target locations for the player to run to. When colliding with the barking area, the player will run to the closest of the targets. After making this doghouse script I knew I had to use this system for the climbing as well. In order to make this work as best as possible, I would change the script for climbing to use an array for the three target objects as opposed to just the single object. This way I could modularly make the climb as wide as I need depending on the climbable area. This is shown in this lattice here. The climbable object is wide enough to fit the width of the lattice and uses three sets of target objects.

Looking back at the process I went through to make this system, it amazes me how obvious it should have been to me to make the system like this from the start. This goes to show that having the right end-goal in mind is very important for making an effective script without needing to rework it too many times. That being said, I hope you learned something useful about game objects being used as targets, and I thank you for reading till the end!

Get Not so Trash Panda

Leave a comment

Log in with itch.io to leave a comment.