Thanks for the follow up, Tony!
I ended up going the route of making a subclass for the ProximitySelector.
This way, I was able to integrate the dialogue system into my custom PlayerController Class. My player states are driven by a state machine. I created a new speaking state that disables movement and sets the animator to play the Idle animation.
So, to hook this all up, I did this:
Code: Select all
if (playerController.myController.isGrounded)
{
playerController.stateMachine.ChangeState<HDialogueState>();
base.UseCurrentSelection();
}
then, I added an OnConversationEnd() event to leave the speaking state and gain control by returning to the idle state.
This worked, however, it created a problem. I didn't realize that "UseCurrentSelection()" would always execute. Even if you weren't in range of a usable NPC. So when I pressed the firekey at a random point in the map, my player would always enter the speaking state and get stuck with no control.
To fix this, I added the condition
Code: Select all
"if ((currentUsable != null) && currentUsable.enabled && (currentUsable.gameObject != null) && (Time.time >= timeToEnableUseButton))"
All together, it looks like this:
Code: Select all
public override void UseCurrentSelection()
{
if ((currentUsable != null) && currentUsable.enabled && (currentUsable.gameObject != null) && (Time.time >= timeToEnableUseButton))
{
if (playerController.myController.isGrounded)
{
playerController.stateMachine.ChangeState<HDialogueState>();
base.UseCurrentSelection();
}
}
}
Seems to be working perfectly now. However, I would like to make sure its future proof.
Are there any issues with how I am currently doing this?