I've spent a lot of time working on the scene that the Forgotten Fields demo ends on - Ethan's house and the surrounding neighborhood area. A lot of that time has been spent on making this place feel atmospheric, warm and alive.
Fun backstory - the vibe of this place has been inspired by a random dead end road that my friends and I discovered after we got lost and took a wrong turn. It's a pretty basic spot, but it's also special - there are fields on one side of the road, two railway tracks that run parallel to the road on the other side, and some old houses a little distance away on the third side. This place has become one of our favorite hang out spots ever, and so of course, I decided to add it to the game.
The spot in monsoons-
The fields are golden and the rest of the foliage is brown in the drier months (which is when the game is set)
The focus of this post is on those previously mentioned trains, and how game dev is quite a bit like film making in that a lot of the things you see are actually illusions and magic. There's some weird stuff going on behind the scenes! If don't want to break immersion, maybe skip this post (or the last part of it) The trains are only set up as a part of the background to add atmosphere to the place and also as a reference to the place that has inspired this area in the game. You can't get on them!
Now first of all, The trains are set up as "NPCs" (through the plugin Adventure Creator) which basically allows me to set up their back and forth movement on the tracks using AC's "paths" system. This helps me avoid having to animate the trains. The paths system also has the option to pause at every node, which means that the trains won't be running back and forth all the time and will instead pass by at more realistic time intervals. Simple, but nifty.
The blue boxes or bogies on one of those trains are the typical sort you see in Indian passenger trains, and are immediately recognizable to anyone that has traveled by or ever seen them.
Having got the movement sorted, the next most important part to figure out was the sound of the trains passing by. This sound should only play when the train is close to the player.
To make sure that the sounds stop after the train is out of earshot, I set up these triggers (the red boxes) on either side of the playable area to recognize the train and only then turn the sound component on. The sound turns off automatically once the audio clip ends (it's about 20 seconds long only) as it is not set to loop. The triggers (also a part of AC) are set up to recognize if the sound is already playing, so that they don't launch the audio clip twice.
The sound component itself is attached to the train, twice - one at the head, near the engine, and one at the end, so that the audio plays continuously and seamlessly for the full duration of the train's passage past the player. Unity also allows you to set it up as a 3D sound with doppler effect. You can see it all in action here in this video -
I think it sounds pretty good!
Another fun little thing going on behind the scenes that amused me is that the house that you see in the picture below falls right on top of the tracks. This house is only seen once, in the shot seen below, and it had to be placed on that spot to fill up the scene and make the world seem more realistic.
Behind the scenes though, you've actually got trains running through it! But with the way the camera is set up (isometric) you'll never really see the train going into the house during gameplay. Check out the immersion breaking phenomenon below -
Thanks for reading, and see you in the next devlog! :)