Dev Diary - Barnstorming Remake: Interactions

A key component of Barnstorming is interacting with objects. Going through barns and colliding with obstacles is what the game is made up of. So in my remake, doing these things right was important.


Each interactable object (gas stations, potholes and fallen trees) has a trigger or collider, yet in the case of the gas station, three. The gas station has two seperate empty game objects attached to the model. One is for the solid obstacle colliders, and the other is for the passthrough trigger.

The "Collider" object has two box colliders which are for the building on the station and for the gas pumps. The "Passthrough" object has one box collider set as a trigger. The "Collider" colliders are tagged as "SolidObstical". While the "Passthrough" collider has a GasStationPassthrough script which checks for the player driving through.


This is the code above. It simply checks for the player (who is tagged as "Player") and then calls the onGasStationPassthrough event, which flips up the flag, plays the sfx, counts down the gas stations remaining and triggers the UI to pop.


Here is where most of the interactions get triggered from. It's attached to the player script and they are checking for two things. Objects tagged as "SolidObstical" and "NonSolidObstical". Solid obstacle are gas station colliders and fallen trees, while non solid obstacles are potholes.

If you go over a solid one, the player knocks back, the particle effect triggers, sound effect and animation are played. The camera shakes also. If you go over a non solid one, the car slows down and the slow down animation is played. You can read more about the knockback and slowdown systems here.


The farmhouse has another box collider on it, set as a trigger. The player doesn't manage this interaction, but the Farmhouse.cs script does (which is attached to the farmhouse). 

It's similar to the GasStationPassthrough.cs script, yet all it does is call the end game event, essentially ending the game.