Quantcast
Channel: Questions in topic: "ragdoll"
Viewing all articles
Browse latest Browse all 565

C# Ragdoll Collision Play A Single Sound

$
0
0
Hey guys, I've been trying to solve this on my own but it's beginning to drive me crazy. I have a scenario where upon left clicking, your character "kicks" - I wanted to add a sound effect so that whenever "justin" is kicked, you can hear it. For Justin I used Unitys ragdoll creation utility (Create -> Other -> Ragdoll) and he functions properly. The problem is that I can't really assign his parent a box collider because of the way his limbs look to trigger a sound, or if I tag every one of his contact points as "justin" the sound will play like 4/5 times at once. How can I script it so that when initial contact with any of Justins limbs is made, the sound will only play once, and not again until the animation re-starts? Here is my sound script attached to the leg used for the kicking: AudioSource kicksound; // Use this for initialization void Start () { kicksound = GetComponent(typeof(AudioSource)) as AudioSource; } void OnCollisionEnter(Collision other) { if (other.gameObject.tag == "justin") { kicksound.Play(); } } Would love a response, thanks in advance!

Viewing all articles
Browse latest Browse all 565

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>