C#
C#

help

Root Question Message

BigBoot
BigBoot2/21/2023
❔ 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
BigBoot
BigBoot2/21/2023
it looks like it should work, right?
Buddy
Buddy2/21/2023
Make sure you include a screenshot of the rigidbody and the collider
Buddy
Buddy2/21/2023
in unity inspector
BigBoot
BigBoot2/21/2023
oh do they need a rigidbody too?
Buddy
Buddy2/21/2023
Of course
BigBoot
BigBoot2/21/2023
ah
Buddy
Buddy2/21/2023
The gameobject you want to listen to trigger events must have rigidbody component
Buddy
Buddy2/21/2023
Also the collider component must be set to trigger
BigBoot
BigBoot2/21/2023
the enemy im trying to destroy is checkes off as a trigger
BigBoot
BigBoot2/21/2023
does the projectile also need to be a rigidbody?
Buddy
Buddy2/21/2023
if you want to listen for trigger events on the projectile, yes.
BigBoot
BigBoot2/21/2023
ok thanks
BigBoot
BigBoot2/21/2023
still passing through eachother
Buddy
Buddy2/21/2023
screenshot
Buddy
Buddy2/21/2023
the inspectors
BigBoot
BigBoot2/21/2023
Buddy
Buddy2/21/2023
Which one of those is the one that you have the script with 'OnTriggerEnter' on?
BigBoot
BigBoot2/21/2023
the laser
Buddy
Buddy2/21/2023
Buddy
Buddy2/21/2023
That need to be a trigger
BigBoot
BigBoot2/21/2023
ok
BigBoot
BigBoot2/21/2023
when i went step by step they destroyed eachother, so i guess one is going too fast
Buddy
Buddy2/21/2023
Yes, it usually is an issue.
BigBoot
BigBoot2/21/2023
lowered the projectile's speed and it worked just fine, thanks for the help!
Buddy
Buddy2/21/2023
I recommend this
Buddy
Buddy2/21/2023
That way the speed of the projectile does not matter - It will always detect a hit even if it goes (0, 0, -10000).
ContactFrequently Asked QuestionsJoin The DiscordBugs & Feature RequestsTerms & Privacy