Implementing vehicle sound


Implementing sounds was a bit trickier, as the script I created had to transition from idle-to-driving (and vice versa), randomly play other idle sounds when not moving, and play a sound when it hits surfaces. This was done by a modular script which referenced the main vehicle movement script, almost all of the variables in use being from the movement script - which was how I discovered how to properly communicate between scripts. 

If the player input was above or below 0 the car would move, so attaching a fade-in/fade-out function to that allowed a smooth transition between the driving and idle sounds. 

The idle revving of the engine was also solved via a countdown, that upon finishing would play a random idle sound. This would only be active when the vehicle was at a stand-still.

The impact sound was also solved, by checking the magnitude of a collision with any surface, and playing 1 of 4 crash sounds accordingly.

Leave a comment

Log in with itch.io to leave a comment.