I have a game where I am dropping blocks onto a wooden platform. The idea of the game is to stack them whilst keeping them balanced.
The blocks fall from a height. Sometimes they land on the plank, other times on other blocks. Players will opt to stack them close together.
I want to make a noise when the block hits something, so I have the following code:
void OnCollisionEnter(Collision other)
{
Debug.Log("Cube collided");
Debug.Log(other.collider.GetComponent<Collider>().tag);
GetComponent<AudioSource>().Play();
}
This is attached to my block.
The sound plays, however it feels extremely unrealistic. The block makes the same noise no matter what the velocity of the impact. If a block becomes jammed between other blocks then it makes a few sounds, all of the same sound it makes when hitting the plank from a height.
Is there a way of creating more realistic 3D sounds? I guess I'm after a noise and falloff based off of the velocity, but that might not be the case, I'm a little unsure. This seems like a very common usecase but I am struggling to find anything online about it.