|
Hello all. I have a simple script that makes a locker make 2 different sounds depending on what it collides with. If it collides with concrete it makes one sound and if it collides with another locker it makes a different sound. Here it is:
The problem I am getting is that at the start of the game the locker collides with the floor instantly and the sound goes off. Then because the locker never actually leaves the floor it doesn't make the sound again when I push it over. It collides with the other locker quite nicely so I know there isn't a problem as such with the code, it just needs something adding to it to keep it updating every time the locker collides with the floor.
(comments are locked)
|
|
You could probably fix this by examining the relativeVelocity reported by the collision in the OnCollisionStay method, and playing a sound if it exceeds some threshold. You could even change the volume of the sound based on the relativeVelocity. Something like this:
(comments are locked)
|
|
Figured it out now. It's very similar to what Duck sugested.
I decided to take out the difference in sound files as this was complicating things a little and made some funny sounds but you can add it back in quite easily.
(comments are locked)
|
|
I am not a coder but I had something similiar ... If your locker is always on the concrete then you shouldn't use the collision with the concrete to activate the sound. Try to link it when you character is pulling it iPushLocker = true;. you should also consider looping the sound while you push...
and then add onCollisionExit to set the IPushLocker as false. Hope it helps a bit.
(comments are locked)
|
