Collision Not Always Working? - SOLVED

I was going through this chapter and importing my enemy ships and noticed that sometimes there is no collision on them and I don’t understand why! I checked my code against Ricks and everything appears to be similar, just wondering if anyone knows why? Hit Box is pretty large so I don’t know why it misses sometimes. Attached a short video as well showing what I mean.

EDIT - Found my solution! In video “43_AA_UY3” Rick mentions turning collision boxes causing issues and in his case he turned off “Enable Tree Collider” under the terrain and it worked for him. I tried that as well and now I have collision. Which means I deleted half my level for no reason, but at least it’s working now and I’ll just rebuild it better!

2 Likes

Hi Nastadon,

What do you mean by “not always working”? How did you check that? Via Debug.Log?

And which collision does not work? The lasers hitting the enemies? If so, check if the enemies have got Rigidbody components attached. If they don’t, add one to each enemy.

Hi Nina, thanks for the reply. I have in my script to enable Rigidbody, but I did try adding the component myself and that didn’t work.

I did test it using Debug.Log and I can shot the small pest ships in the beginning, and I can shoot the large boss ship, however if I shoot these ships then I cannot hit the medium sized ship. If I ignore first ships I’m able to hit the medium ship just fine every time. Not really sure why! I’ll just ignore it for now and add more ships and hope it doesn’t become a worse problem after lol

Could there be a collider in the foreground which blocks the shooting?

And have you already tried to add Debug.Logs to your code to see what is going on during runtime? You could, for example, log the name of the colliding game object into your console.

It was the trees I had put on my terrain. Somehow they were blocking the ships after X amount of hits, so I just disabled the collision on them and everything works fine!

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms