Hello,
I’m actually making a system where when my ball touch the ground, a hit sound is playing. I’m using this piece of code:
void OnCollisionEnter(Collision hit)
{
if(hit.gameObject.tag == "Floor")
{
hitball.volume = speed/(maxSpeed);
hitball.pitch = speed/(maxSpeed);
hitball.PlayOneShot(ballhit);
}
}
It works perfectly, but my problem is that my maps are built with blocks, so everytime I reach a new block, the sound is playing.
I so had the idea to check what’s the previous tag so the sound doesn’t play when the next tag is the same. But that’s what I’m searching for, and I don’t really know how to do it.
So, can someone explain me how can I get it to work?
Thanks.