Prevent Usable use through wall?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
random
Posts: 34
Joined: Thu May 09, 2024 10:48 pm

Prevent Usable use through wall?

Post by random »

Hello,

Pretty much the title! I'm able to start a conversation through a wall. Is there some way to prevent this?
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: Prevent Usable use through wall?

Post by Tony Li »

Hi,

Add walls to your Selector's Layer Mask so it can detect them.
random
Posts: 34
Joined: Thu May 09, 2024 10:48 pm

Re: Prevent Usable use through wall?

Post by random »

I tried that but it still doesn't seem to be working.
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: Prevent Usable use through wall?

Post 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 620 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 620 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.
random
Posts: 34
Joined: Thu May 09, 2024 10:48 pm

Re: Prevent Usable use through wall?

Post 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 616 times
Is there a setting elsewhere that may be affecting this?
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: Prevent Usable use through wall?

Post 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?
random
Posts: 34
Joined: Thu May 09, 2024 10:48 pm

Re: Prevent Usable use through wall?

Post 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.
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: Prevent Usable use through wall?

Post 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?
random
Posts: 34
Joined: Thu May 09, 2024 10:48 pm

Re: Prevent Usable use through wall?

Post by random »

Here is the wall
Example.png
Example.png (149.01 KiB) Viewed 580 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.
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: Prevent Usable use through wall?

Post 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.
Post Reply