❔ Trigger collisions not being detected?
I am following an official Unity course online, with a lab where you work on your own game, my code looks like it should work but the projectile just passes through the enemy without destroying it
21 Replies
it looks like it should work, right?
Make sure you include a screenshot of the rigidbody and the collider
in unity inspector
oh do they need a rigidbody too?
Of course
ah
The gameobject you want to listen to trigger events must have rigidbody component
Also the collider component must be set to trigger
the enemy im trying to destroy is checkes off as a trigger
does the projectile also need to be a rigidbody?
if you want to listen for trigger events on the projectile, yes.
ok thanks
still passing through eachother
screenshot
the inspectors
Which one of those is the one that you have the script with 'OnTriggerEnter' on?
the laser
That need to be a trigger
ok
when i went step by step they destroyed eachother, so i guess one is going too fast
Yes, it usually is an issue.
lowered the projectile's speed and it worked just fine, thanks for the help!
Codeer
YouTube
Unity accurate projectiles in 6 steps
This video explains how you can make fast moving projectiles/bullets that still have accurate hit detection.
I recommend this
That way the speed of the projectile does not matter - It will always detect a hit even if it goes (0, 0, -10000).
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.