Mouse Selection Trouble

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
AlexNerd
Posts: 39
Joined: Sat Jun 29, 2019 11:46 am

Mouse Selection Trouble

Post by AlexNerd »

Hi there,

I'm trying to make it so the player can use objects by clicking on them, and I've set input to "Mouse 0". I've tried to start a conversation on the use of both a 2D and 3D object, both of which have colliders and a "usable" component.

From what I can tell the raycast is hitting the 3D object, but it's not working and I'm not sure why. Also, is there any way to use the raycast with a 2D sprite? Thanks.
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Mouse Selection Trouble

Post by Tony Li »

Hi Alex,

Assuming you're using a Selector component, here are some things to check:
  • Selector's Select At dropdown is set to "Mouse Position".
  • The Layer Mask is correct to pick up the Usable that you're trying to detect.
  • Max Selection Distance is high enough.
  • For 2D:
    • Select Tools > Pixel Crushers > Dialogue System > Welcome Window. Make sure the 2D Physics checkbox is ticked.
    • Set your camera to Orthographic.
    • Set the Selector's Run Raycasts dropdown to "In 2D".
    • If you're mixing 2D and 3D, just use 3D colliders for everything.
If you're running raycasts in 3D and you tick the Selector's Debug checkbox, it will show what 3D objects it's detected:

Image

In the Scene view (on the left), the yellow line is the raycast from the camera. It detected the NPC, Private Hart, so it drew a green sphere at the detection point.
Post Reply