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
BigBoot2/21/2023
it looks like it should work, right?
Buddy2/21/2023
Make sure you include a screenshot of the rigidbody and the collider
Buddy2/21/2023
in unity inspector
BigBoot2/21/2023
oh do they need a rigidbody too?
Buddy2/21/2023
Of course
BigBoot2/21/2023
ah
Buddy2/21/2023
The gameobject you want to listen to trigger events must have rigidbody component
Buddy2/21/2023
Also the collider component must be set to trigger
BigBoot2/21/2023
the enemy im trying to destroy is checkes off as a trigger
BigBoot2/21/2023
does the projectile also need to be a rigidbody?
Buddy2/21/2023
if you want to listen for trigger events on the projectile, yes.
BigBoot2/21/2023
ok thanks
BigBoot2/21/2023
still passing through eachother
Buddy2/21/2023
screenshot
Buddy2/21/2023
the inspectors
BigBoot2/21/2023
Buddy2/21/2023
Which one of those is the one that you have the script with 'OnTriggerEnter' on?
BigBoot2/21/2023
the laser
Buddy2/21/2023
Buddy2/21/2023
That need to be a trigger
BigBoot2/21/2023
ok
BigBoot2/21/2023
when i went step by step they destroyed eachother, so i guess one is going too fast
Buddy2/21/2023
Yes, it usually is an issue.
BigBoot2/21/2023
lowered the projectile's speed and it worked just fine, thanks for the help!