Hi Tony, hope you are doing well!
I am currently working on my generic NPCs. That is, NPCs that hold no big purpose in the game besides making the world feel alive.
My NPCs patrol around and can have different states (crying, dancing, talking etc.).
Is there a simple way to simply check for the NPC state? I was going to write a custom sequencer script, but don't see it working since there is seemingly no method of sequencer scripts to return a value.
As I stated, these NPCs are really generic. I wouldn't want to assign a unique actor for each NPC I have roaming around.
Any tips on my situation?
Check arbitrary NPC conditions
Re: Check arbitrary NPC conditions
Hi,
Write C# function(s) to check -- for example, a single GetNpcState() that returns a string ("crying", "dancing", etc.); or, if you prefer, multiple functions such as IsCrying(), IsDancing(), etc. Then register them with Lua and use them in dialogue entry nodes' Conditions fields.
More info:
Other notes for generic NPCs:
Write C# function(s) to check -- for example, a single GetNpcState() that returns a string ("crying", "dancing", etc.); or, if you prefer, multiple functions such as IsCrying(), IsDancing(), etc. Then register them with Lua and use them in dialogue entry nodes' Conditions fields.
More info:
Other notes for generic NPCs:
- Character GameObject Assignments
- Special Lua Variables (e.g., use [var=Conversant] in Dialogue Text to show NPC's name.
Re: Check arbitrary NPC conditions
Hi and thanks for your reply.
Is there any other way to check the state besides the GetNPCState(string NpcName)? I believe I would have to pass some kind of argument to specify the NPC I am interested in. Or is there way to just call GetNPCState that would always target the current NPC I am talking to.
I am a bit worried about performance if I have lot's of gameobjects or NPCs roaming around.
Is there any other way to check the state besides the GetNPCState(string NpcName)? I believe I would have to pass some kind of argument to specify the NPC I am interested in. Or is there way to just call GetNPCState that would always target the current NPC I am talking to.
I am a bit worried about performance if I have lot's of gameobjects or NPCs roaming around.
Re: Check arbitrary NPC conditions
You don't have to pass the NPC name. You can check DialogueManager.currentConversant to get a reference to the NPC. The call to GetNPCState() would be pretty fast. The built-in Lua implementation is written in C#, so there's no C++/C# barrier to cross (with associated overhead) or anything like that.
If you're running simultaneous conversations, you may have to adjust that approach slightly.
If you're running simultaneous conversations, you may have to adjust that approach slightly.
Re: Check arbitrary NPC conditions
Glad to help!