Quantcast
Channel: Questions in topic: "gun"
Viewing all articles
Browse latest Browse all 592

OnTriggerEnter is often not working

$
0
0
I'm trying to make a shooting system. I use rigidbodys for the bullets and I want to make the hit detection with the a hitbox of the ridgidbody object. I'm using the "OnThriggerEnter"-function for that. But for some reason, the function is working sometimes and sometimes not. Sometimes the script does what it should do and sometimes, my bullet is just flying thought the object. That's my script: Script on Objects: import UnityEngine class DamageTaker (MonoBehaviour): health as int = 300 def Update (): if health <= 0: self.die() def ApplyDamage(dmg as int): health -= dmg def die(): #Sterbeanimation Destroy(gameObject) Script on bullet object: import UnityEngine class BulletDamageScript (MonoBehaviour): dmg as int = 50 def OnTriggerEnter (hitObj as Collider): hitObj.SendMessage("ApplyDamage", dmg, SendMessageOptions.DontRequireReceiver) Destroy(gameObject) As you can see, the language is Boo.

Viewing all articles
Browse latest Browse all 592

Trending Articles



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