- Home /
This question was
closed Aug 08, 2017 at 12:16 AM by
seanjust530 for the following reason:
I was able to solve my problem.
Question by
seanjust530 · Aug 07, 2017 at 09:52 PM ·
physics3daudio
Audio for object collision
So I have my object (sphere) and when it collides with the ground it makes a collision sound. It seems to work really well by checking if the player collides with an object tagged ground except when I have two grounds next to each other and the sphere crosses from one to the next it also plays the collision audio which is really annoying since my levels have many grounds next to each other. I was thinking I might need to use raycast but I have no clue where to start, I tried using Pyshics.Raycast but I'm having a hard time getting it to work.
Here is the script for my sphere:
void OnCollisionEnter(Collision other)
{
if (other.collider.gameObject.CompareTag("Ground"))
{
ballCollide.Play();
}
}
Comment
Answer by seanjust530 · Aug 08, 2017 at 12:16 AM
Nevermind I was able to figure out after tinkering around for a while. :D