proximity selector

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Pearl.F.Cook
Posts: 1
Joined: Tue Sep 18, 2018 5:38 am

proximity selector

Post by Pearl.F.Cook »

why need a npc with rigid body to work?
i try without this, but don't worked
User avatar
Tony Li
Posts: 22145
Joined: Thu Jul 18, 2013 1:27 pm

Re: proximity selector

Post by Tony Li »

Hi,

Proximity Selector uses Unity's OnTriggerEnter and OnTriggerExit messages (or their 2D equivalents). Unity's physics requires rigidbodies. Here is a tutorial on Colliders as Triggers that you might find helpful.

You can use other techniques to start conversations and trigger other Dialogue System activity. But if you want to use Proximity Selector, you must set it up for Unity's physics.
User avatar
focusonfungames
Posts: 17
Joined: Thu Jun 07, 2018 10:21 pm

Re: proximity selector

Post by focusonfungames »

I spent a fair bit of time trying to get the Proximity Selector working, myself. In the end, it was because I didn't have a Sphere Collider set as Trigger on my player game object. It's assumed in all of the documentation (I think) that the player has this set up. It's obvious, looking back, but until I figured this out, I was pretty stumped!
User avatar
Tony Li
Posts: 22145
Joined: Thu Jul 18, 2013 1:27 pm

Re: proximity selector

Post by Tony Li »

Thanks for the feedback. I'll make sure to clarify that in the next update's documentation.
User avatar
focusonfungames
Posts: 17
Joined: Thu Jun 07, 2018 10:21 pm

Re: proximity selector

Post by focusonfungames »

What I've seen other libraries, specifically VRTK, do is provide a public Collider variable attached to the script. If that value is null then the script creates a collider on that game object automatically/dynamically. This way, you can specify your own collider (likely you'll want to) but it'll still work the first time you run it even if you don't set it manually.

I assume your Proximity Selector script is doing a GetComponent<Collider> to grab the collider at run-time. Instead, it would just use the public Collider variable.
User avatar
Tony Li
Posts: 22145
Joined: Thu Jul 18, 2013 1:27 pm

Re: proximity selector

Post by Tony Li »

VRTK requires things to work exactly one way. With the Proximity Selector, on the other hand, the trigger collider can be on the player or on the usable objects (e.g., NPCs). And if it's on the player, different devs want different size trigger colliders. For these reasons, it isn't practical to automatically add a collider to the player. However, I can update it to at least check for any kind of collider and log a message if it doesn't have anything.
User avatar
focusonfungames
Posts: 17
Joined: Thu Jun 07, 2018 10:21 pm

Re: proximity selector

Post by focusonfungames »

Got it. Thanks!
Post Reply