Page 1 of 1

Prevent Usable use through wall?

Posted: Tue May 14, 2024 8:01 pm
by random
Hello,

Pretty much the title! I'm able to start a conversation through a wall. Is there some way to prevent this?

Re: Prevent Usable use through wall?

Posted: Tue May 14, 2024 9:05 pm
by Tony Li
Hi,

Add walls to your Selector's Layer Mask so it can detect them.

Re: Prevent Usable use through wall?

Posted: Tue May 14, 2024 9:38 pm
by random
I tried that but it still doesn't seem to be working.

Re: Prevent Usable use through wall?

Posted: Wed May 15, 2024 8:45 am
by Tony Li
Make sure Raycast All is not turned on, since this will go through GameObjects.

Tick your Selector's Debug checkbox. This will show a debugging gizmo. Here's a screenshot of the gizmo where the Selector's raycast is not blocked:

unblocked.png
unblocked.png (813.43 KiB) Viewed 831 times

You can see that the yellow raycast line ends in a green sphere where it detects the Usable (Private Hart).

And here's a screenshot where it's blocked:

blocked.png
blocked.png (651.82 KiB) Viewed 831 times

You can see that the red sphere indicates where it's blocked.

You can test the same thing yourself. If you need a copy of the scene, let me know, but I just added a cube with dimensions (2,2,0.5) to DemoScene1.

Re: Prevent Usable use through wall?

Posted: Wed May 15, 2024 9:30 am
by random
Yeah, I'm not sure what's going on, it still doesn't seem to be working, even the debug isn't showing up for me.

Here is my selector settings.
Screenshot 2024-05-15 092923.png
Screenshot 2024-05-15 092923.png (77 KiB) Viewed 827 times
Is there a setting elsewhere that may be affecting this?

Re: Prevent Usable use through wall?

Posted: Wed May 15, 2024 12:41 pm
by Tony Li
Hi,

I didn't realize you were in 2D. The Debug checkbox works in 3D.

Does your 2D wall have a collider?

Re: Prevent Usable use through wall?

Posted: Wed May 15, 2024 2:21 pm
by random
Yeah, I probably should have mentioned I was in 2D, my apologies.

It does yeah, it's a tilemap with a tilemap/composite collider on it.

Re: Prevent Usable use through wall?

Posted: Wed May 15, 2024 4:28 pm
by Tony Li
Can you post a screenshot of the wall? Or send a reproduction project to tony (at) pixelcrushers.com? Is the Usable behind the wall? If so, is it really behind it in a raycast (Z axis) sense, or is it just being drawn like it's behind it because of the sprite sort order?

Re: Prevent Usable use through wall?

Posted: Thu May 16, 2024 6:52 pm
by random
Here is the wall
Example.png
Example.png (149.01 KiB) Viewed 791 times
Well, it's more like the other side of a wall, or more accurately, through a collider.

Perhaps I actually misunderstood. Is the raycast done from the player's position to the mouse point (assuming you have mouse point selected) or is it from the camera directly to the mouse point. After seeing the option to set the point of where the distance is measured, I unintentionally made the assumption that the raycast is from player position to the mouse position.

Re: Prevent Usable use through wall?

Posted: Thu May 16, 2024 7:15 pm
by Tony Li
Hi,

It's done from the camera. So it sounds like you've identified the issue. The Selector component isn't mandatory. You can use whatever technique of your own to trigger Dialogue System Triggers.