C
C#2y ago
BigBoot

❔ 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
BigBoot
BigBootOP2y ago
it looks like it should work, right?
Buddy
Buddy2y ago
Make sure you include a screenshot of the rigidbody and the collider in unity inspector
BigBoot
BigBootOP2y ago
oh do they need a rigidbody too?
Buddy
Buddy2y ago
Of course
BigBoot
BigBootOP2y ago
ah
Buddy
Buddy2y ago
The gameobject you want to listen to trigger events must have rigidbody component Also the collider component must be set to trigger
BigBoot
BigBootOP2y ago
the enemy im trying to destroy is checkes off as a trigger does the projectile also need to be a rigidbody?
Buddy
Buddy2y ago
if you want to listen for trigger events on the projectile, yes.
BigBoot
BigBootOP2y ago
ok thanks still passing through eachother
Buddy
Buddy2y ago
screenshot the inspectors
BigBoot
BigBootOP2y ago
Buddy
Buddy2y ago
Which one of those is the one that you have the script with 'OnTriggerEnter' on?
BigBoot
BigBootOP2y ago
the laser
Buddy
Buddy2y ago
Buddy
Buddy2y ago
That need to be a trigger
BigBoot
BigBootOP2y ago
ok when i went step by step they destroyed eachother, so i guess one is going too fast
Buddy
Buddy2y ago
Yes, it usually is an issue.
BigBoot
BigBootOP2y ago
lowered the projectile's speed and it worked just fine, thanks for the help!
Buddy
Buddy2y ago
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.
Buddy
Buddy2y ago
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).
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server