Page 1 of 1

proximity selector

Posted: Tue Sep 18, 2018 5:45 am
by Pearl.F.Cook
why need a npc with rigid body to work?
i try without this, but don't worked

Re: proximity selector

Posted: Tue Sep 18, 2018 8:27 am
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.

Re: proximity selector

Posted: Sun Sep 23, 2018 2:32 pm
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!

Re: proximity selector

Posted: Sun Sep 23, 2018 3:08 pm
by Tony Li
Thanks for the feedback. I'll make sure to clarify that in the next update's documentation.

Re: proximity selector

Posted: Sun Sep 23, 2018 7:09 pm
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.

Re: proximity selector

Posted: Sun Sep 23, 2018 8:03 pm
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.

Re: proximity selector

Posted: Sun Sep 23, 2018 8:04 pm
by focusonfungames
Got it. Thanks!