I'm having major trouble with getting started. I've watched the tutorial series on you tube, and read through the starting docs. I've even managed to get it working in the demo scene, but as soon as I move into my own project, the Selector isn't registering for onUse/onTrigger etc.
I've triple checked the list provided in the FAQs around Selectors in a 2D world (2D collider, layer, 9999 detection distance, runRaycasts, orthographic camera, disabled my entire UI), and tried on multiple different objects but no luck. I know the UI etc. is working because I can get 'onStart' to work just fine, it's just the Selector that isn't playing ball. Is there a way I can see what the raycast is doing or somehow see more information on what has gone wrong?
Selector in 2D not working
Re: Selector in 2D not working
Hi,
You've probably already gone through How To: Fix Selector Issues, but here are some things to check:
You've probably already gone through How To: Fix Selector Issues, but here are some things to check:
- 2D Only: Camera is set to Orthographic.
- 2D Only: Scripting define symbol USE_PHYSICS2D is set.
- GameObject with Usable component and Dialogue System Trigger has a collider that's enabled.
- GameObject is on a layer included in the Selector's Layer Mask.
- Set Selector's Max Selection Distance is far enough for a raycast from the camera to reach it.
- Run Raycasts is set to In 2D or 3D depending on whether you're using 2D or 3D colliders..
- A transparent UI element isn't blocking collider.
Re: Selector in 2D not working
Yeah, I'm afraid I've tried those already. I'm in a 2D environment, and all of those things look fine, as far as I can tell. I'm trying to import it into unity's example platformer, if that helps?
Re: Selector in 2D not working
There shouldn't be any issue with Unity's example platformer.
Can you send a reproduction project to tony (at) pixelcrushers.com?
Can you send a reproduction project to tony (at) pixelcrushers.com?
Re: Selector in 2D not working
Thanks for sending the reproduction project.
The Player's Selector is configured to check for Usables that are on the Default layer:
But the Enemy is on an undefined layer:
Normally, simply setting the Enemy to the Default layer will allow the Selector to detect it:
However, Cinemachine throws a wrench into that idea because it has a GameObject named "CinemachineConfiner" that's also on the Default layer and blocks the Selector's raycast. If you change CinemachineConfiner to a different layer, such as Ignore Raycast, it won't block the Selector.
Alternatively, you could tick the Selector's Raycast All checkbox. This tells the Selector to run a raycast through everything it hits, ignoring closer blocking objects that don't have Usable components, until it finds a Usable component.
Another alternative would be to change the Enemy's layer to a new layer such as "Enemy", and set the Selector's Layer Mask to that same layer.
The Player's Selector is configured to check for Usables that are on the Default layer:
But the Enemy is on an undefined layer:
Normally, simply setting the Enemy to the Default layer will allow the Selector to detect it:
However, Cinemachine throws a wrench into that idea because it has a GameObject named "CinemachineConfiner" that's also on the Default layer and blocks the Selector's raycast. If you change CinemachineConfiner to a different layer, such as Ignore Raycast, it won't block the Selector.
Alternatively, you could tick the Selector's Raycast All checkbox. This tells the Selector to run a raycast through everything it hits, ignoring closer blocking objects that don't have Usable components, until it finds a Usable component.
Another alternative would be to change the Enemy's layer to a new layer such as "Enemy", and set the Selector's Layer Mask to that same layer.