Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Kotep |
I’m trying to wrap my head around a basic RPG-style dialogue system, where NPCs can give a series of responses to a player based on input, game state–whatever arbitrary condition needs to be checked.
At the moment, I have it worked out so that there’s an NPC_base
scene with a script that handles all the nibbly bits of when a player can interact with an NPC and how to write to the dialogue box. Then I have an NPC
scene that extends NPC_base.gd
, so that all I have to write for each NPC is a dialogue()
function with all the necessary messages, condition checks, and so on.
In practice, this means I add instances of the NPC
scene, then go into the inspector, find the panel for its script, and use ‘make unique’ to write out a unique dialogue()
function. I’m not super familiar with Godot though, so I don’t know if I’m making this harder than it needs to be.
Is there an easier way to make a base object and then create instances of it with custom code? (Like for example, a way to define what dialogue()
does per-instance without having to give each NPC instance its own custom script?)