Disable/Enable the Proximity Selector

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
PandaBOX
Posts: 8
Joined: Fri Aug 23, 2019 1:56 am

Disable/Enable the Proximity Selector

Post by PandaBOX »

Hello there! :D

I've been trying to disable the proximity selector via script and it's not really working out. I'm trying to disable it when my character is jumping, then enable it again when they are grounded.

This is all the code I have related to the proximity selector:

using PixelCrushers.DialogueSystem;

ProximitySelector proximitySelector = GetComponent<ProximitySelector>().enabled = false;

But I get this error:
BasicWalkerController.cs(337,41): error CS0029: Cannot implicitly convert type 'bool' to 'PixelCrushers.DialogueSystem.ProximitySelector

Sorry if this is a bit simple, but I just can't seem to figure it out.
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: Disable/Enable the Proximity Selector

Post by Tony Li »

Hi,

Remove that first part. Try just this:

Code: Select all

GetComponent<ProximitySelector>().enabled = false;
Or, better yet, look up the ProximitySelector once in Awake and then use that reference whenever you jump:

Code: Select all

private ProximitySelector proximitySelector;
private void Start()
{
    proximitySelector = GetComponent<ProximitySelector>();
}
...
void Jump() // EXAMPLE
{
    proximitySelector.enabled = false;
PandaBOX
Posts: 8
Joined: Fri Aug 23, 2019 1:56 am

Re: Disable/Enable the Proximity Selector

Post by PandaBOX »

Ah, thanks so much! It's working great. I still had to have this part:

using PixelCrushers.DialogueSystem;

Otherwise I would get errors about not knowing what the proximity selector was, but grouped with the code it's working just fine! :D Thanks again Tony!
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: Disable/Enable the Proximity Selector

Post by Tony Li »

Happy to help!
Post Reply