- Home /
collision issues
Hi, i have a sphere rolling on a series of cubes (placed together like a maze). Right now i have an OnCollisionEnter function that plays an impact sound when the ball collides with the cubes. However, I only want the sound to play when the ball impacts the blocks, not when it simply rolls to the next one. Technically it is an "impact" but visually it's just rolling on a flat surface.
So in a nutshell, i want the sound to play when the ball falls and hits a block, but not when it just rolls from one block to the next.
Are there any built in properties/methods that would help me? or does anyone have any scripting ideas?
any help is much appreciated! :)
seem to have alieviated the issue with the following code:
[code] //your code tag is messed up, will post later [/code]
Answer by Anxo · Jun 01, 2011 at 04:25 PM
If you are using a Ridgidbody you can check for the magnitude that the object hits the blocks with and only play the sound if the magnitude is greater than...
I thought of that, but sometimes the ball can roll faster than it free falls. Is there a property or method that will tell me if the ball is colliding with anything? So i could make a script with a boolean that is true when colliding. When not colliding at all it could be set back to false so that OnCollisionEnter will only play the sound when the boolean is false?
Your answer

Follow this Question
Related Questions
How to create a semi-passable barrier 1 Answer
How to check if a collision impact is perpendicular with the velocity of the collider? 0 Answers
Collision detection for specific objects 1 Answer
My collider that is tagged as a trigger is colliding with other colliders 1 Answer
Bullet Shoot with RayCast don't destroy onCollisionEnter 1 Answer