Unit selection collider not working as expected

Firstly, thank you for this great course! I’ve made about 4 smaller games and this is the perfect level for me to realise that I know more than I thought but still have a lot of exciting things to learn.

Snip below shows where I have the box collider set up, however in-game it doesn’t trigger from clicks anywhere except just around the unit’s head. It isn’t offset, as the collider also doesn’t register clicks above or either side of the head, so it seems like only a small part of the collider actually registers clicks and I am not sure why.

So everything else is working fine (I’ve finished the next three lectures in case it fixed my issue).

Any help would be appreciated!

1 Like

It looks like you’re using Unity 2022.2 (I don’t believe previous versions have the Provides Contacts and Layer Overrides…
Make sure that your Layer Overrides aren’t conflicting with the Units layer.

Make sure you’re testing for the Units layer in your code

1 Like

Thanks for your reply! I’m running into a few (predictable, my mistake) issues so will restart the course with Unity 2022.1. Is it best to use 2022.1.24 (the last 2022.1 update)?

1 Like

Probably, but I’m not entirely convinced that 2022.2 can’t be used…
I was mainly pointing out the potential that the layer overrides were an issue.

Mostly likely, the layer you’re testing for isn’t the correct layer.

1 Like

Maybe you have something blocking the raycast? Can you move the camera and click? It only detects the head regardless of camera position?
Maybe you have a Floor collider with an invisible mesh at head height

1 Like

I have since completed the cinemachine camera section and this problem persists regardless of camera location/angle/zoom.

I’ve checked for colliders in the scene but haven’t found any that might be interfering.

Zip up your project and upload it to https://gdev.tv/projectupload. Be sure to remove the Library folder from the Zip to save space.

Thanks – have submitted. Appreciate the support!

Edit: just to confirm that I have NOT restarted the project with 2022.1 as I had considered earlier

Sorry for the delay. I had to download 2022.2.2f1, as I find that opening projects in the same versions works best…

This one stumped me for a few moments, because the usual suspect is transparent frames on UI, but in this case, it’s a collider hiding on the model.

There is a capsule collider on the Astronaut Rig of the Unit. We won’t need it for anything in the course, it’s probably an artifact from whatever asset you got the rig. Delete this collider, and everything should work fine.

Brian, thank you so much!

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

Privacy & Terms