Questions for operating with mouse only

Announcements, support questions, and discussion for the Dialogue System.
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Questions for operating with mouse only

Post by Tony Li »

Then I assume you followed the Interaction Tutorial video you're using a Proximity Selector. If this is NOT the case, let me know.

When you use a Proximity Selector, the Proximity Selector will only check if you're pressing the Use Button input action if you are in range of the NPC.

If your left-click responds for the entire screen, then:

1. Check the trigger collider sizes to make sure they don't cover the whole screen.

2. Make sure you're not also using a Selector component.

3. See: How To: Fix Selector and Proximity Selector Issues

The Interaction Tutorial video's Description has a link to the tutorial assets so you can check for yourself. It uses Unity's built-in input manager, but you can test it in a separate project without the Input System or you can update it to use the Input System.
gaku2_sigehiro
Posts: 36
Joined: Sun Jul 14, 2024 2:35 am

Re: Questions for operating with mouse only

Post by gaku2_sigehiro »

I agree. I'm using Proximity Selector.
The red hair sample was 2D, but the one I'm creating is 3D.
I attached a GameObject to the child of the moving character, and attached a capsule collider and a Proximity Selector to it.

I'll try the number written on it.

The size of the capsule collider of the same GameObject that the Proximity Selector is attached to is about the size of the moving character.
So I think I've cleared 1.

Is the second written “Selector component” referring to a regular “Selector”, not a “Proximity Selector”?
In that case, "Selector" is not used.
I think the second content can also be addressed.

Is the third content the topic "https://pixelcrushers.com/phpbb/viewtop ... f=3&t=4190"?
There are two contents written in the topic, but which of these conversations contains the contents I am looking for?
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Questions for operating with mouse only

Post by Tony Li »

Hi,

I fixed the link.

Please use the second list (Proximity Selector).

The process is the same for 2D and 3D. The only difference is that if you were using 2D you would need to tick the Welcome Window's USE_PHYSICS2D checkbox. But since you're in 3D, you don't need to do that.
gaku2_sigehiro
Posts: 36
Joined: Sun Jul 14, 2024 2:35 am

Re: Questions for operating with mouse only

Post by gaku2_sigehiro »

Erm...Is this the way to talk to an NPC by left-clicking after the character approaches it?
If so, it has already been implemented.

It seems like I can't convey what I want to do very well, so I've prepared an illustration.
please confirm.
240925.jpg
240925.jpg (326.89 KiB) Viewed 156 times
gaku2_sigehiro
Posts: 36
Joined: Sun Jul 14, 2024 2:35 am

Re: Questions for operating with mouse only

Post by gaku2_sigehiro »

I added a picture because the explanation wasn't enough.
Please check here.
240925c.jpg
240925c.jpg (391.02 KiB) Viewed 154 times
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Questions for operating with mouse only

Post by Tony Li »

Hi,

Ah, I understand now! Thank you for the pictures.

In this case, you will want to use a Selector component, not Proximity Selector.

Note: Neither component is required. If you have your own interaction system that you prefer to use, you can use it instead of Selector or Proximity Selector. Just configure it to call the NPC's DialogueSystemTrigger.OnUse() method.

To use a Selector, use these settings:
  • Select At: Mouse Position
  • Distance From: GameObject***
  • Max Selection Distance: Something small, like 1 or 2
*** If the Selector is on your player GameObject, then Distance From: GameObject is fine. If your Selector is another another GameObject, you can set the Selector's Actor Transform to the player, and set Distance From: to Actor Transform.
gaku2_sigehiro
Posts: 36
Joined: Sun Jul 14, 2024 2:35 am

Re: Questions for operating with mouse only

Post by gaku2_sigehiro »

Thank you.
I tried it right away, but there were some concerns.
What settings do I need to make so that I can only speak when facing the NPC?
If you just implement what you are taught, you will be able to talk even if your back is turned.

By the way, although the game is set in a 3D space, the player character's picture is only considered horizontally, not vertically and horizontally.
This is a belt scrolling game.
I would like to create something where if there is an NPC on the right side of the character and you talk to him, the character will turn his face to the right side of the screen and talk to you.
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Questions for operating with mouse only

Post by Tony Li »

That will require some scripting.

Here are two options:

1. Make a subclass of Selector. Override the Run3DRaycast() method. If the mouse cursor is behind the player, call DeselectTarget() instead of calling base.Run3DRaycast().

2. Or use a Proximity Selector instead. Make a subclass of ProximitySelector. Put the Proximity Selector's trigger collider slightly in front of the player so it will only detect NPCs in front of the player. Then override the IsUseButtonDown() function to check if the mouse is over the Usable NPC.
gaku2_sigehiro
Posts: 36
Joined: Sun Jul 14, 2024 2:35 am

Re: Questions for operating with mouse only

Post by gaku2_sigehiro »

Thank you for teaching me the two methods.
Since I use ProximitySelector when operating with a gamepad, I would like to use ProximitySelector when operating with a mouse.
Therefore, if you have any details or articles on how to do method 2, could you please let me know?
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Questions for operating with mouse only

Post by Tony Li »

Hi,

Here's an example scene:

DS_ProximitySelectorWithMouse_2024-09-27.unitypackage

It uses Unity's default input manager and default input values ("Horizontal" and "Vertical").

W & S keys move forward and back.

A & D keys rotate.

Click on cylinder NPC to start conversation.
Post Reply