Re: PUN Networked Quests
Posted: Fri Feb 26, 2021 1:20 am
Hi Tony
Seem to be revisting things I thought I had working, but apparently did not
I have a Custom Sequencer command that I'm trying to send a message to the Master Client NPC to trigger a Behaviour Tree but for some reason it is not working. You mind having a look over this and see if anything stands out to you?
If I have this sequence command in the Sequencer Field on the Dialogue Node, I get this error:
Which looks unrelated to DS, but this error only happens when I have the Sequencer Command in the field, if I remove the command I do not get the error.
The Command Code:
The Sequencer Commands
And the PUN RPC I should mention, in the these examples, the "string action = GetParameter(0);" from the Sequence code is not actually used in this RPC.
As always, your help is most appreciated.
Nathan
Seem to be revisting things I thought I had working, but apparently did not
I have a Custom Sequencer command that I'm trying to send a message to the Master Client NPC to trigger a Behaviour Tree but for some reason it is not working. You mind having a look over this and see if anything stands out to you?
If I have this sequence command in the Sequencer Field on the Dialogue Node, I get this error:
Code: Select all
NullReferenceException: Object reference not set to an instance of an object
Opsive.UltimateCharacterController.AddOns.Multiplayer.PhotonPun.Character.PunLookSource.OnPhotonSerializeView (Photon.Pun.PhotonStream stream, Photon.Pun.PhotonMessageInfo info) (at Assets/Opsive/UltimateCharacterController/Add-Ons/Multiplayer/PhotonPUN/Scripts/Character/PunLookSource.cs:172)
The Command Code:
Code: Select all
namespace PixelCrushers.DialogueSystem.SequencerCommands
{
public class SequencerCommandStartPUNBT : SequencerCommand
{ // Rename to SequencerCommand<YourCommand>
Transform subject = null;
private void Start()
{
string action = GetParameter(0);
string group = GetParameter(1);
subject = GetSubject(2);
string name = subject.name;
PhotonView photonView = PhotonView.Get(subject);
photonView.RPC("TriggerPUNBT", RpcTarget.MasterClient, group, name, action);
Stop();
}
public void OnDestroy()
{
subject = null;
// Add your finalization code here. This is critical. If the sequence is cancelled and this
// command is marked as "required", then only Awake() and OnDestroy() will be called.
// Use it to clean up whatever needs cleaning at the end of the sequencer command.
// If you don't need to do anything at the end, you can delete this method.
}
}
}
Code: Select all
StartPUNBT(start,2,npcName); {{default}}
Code: Select all
[PunRPC]
void TriggerPUNBT(string group, string name, string action)
{
int groupNumber = int.Parse(group);
foreach (BehaviorTree tree in bTs)
{
if (tree.Group == groupNumber)
{
tree.Start();
}
}
}
Nathan