How can I manage the progress of a quest with a variable and make npc appear or disappear depending on the variable?
First of all, I think I need to create a variable, but should I make the origin global in the checkgamevariables node?
  • If what's turning the NPC on or off is in the same scene, I'd recommend using a Game Object Manager component on a separate game object.

    This component can enable/disable other game objects based on defined conditions, e.g. using a global variable or a quest condition.

    Using a variable, I'd recommend using a global variable for this.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • For example, I would like to make the sample npc_green appear or disappear depending on the variable.
    Added Game Object Manager component to npc_green.
    It seems that variable conditions can be set there.

    Variable condition
    condition type variable

    Variable key
    Value type value
    Value A
    is valid check
    type float
    check type s equal
    Value type value
    Value 0

    I wasn't sure, so I set it by guessing. What I wanted to set is that npc appears when the global variable A is 0. I'm not sure what to do.
  • As said - the Game Object Manager needs to be on a different game object. If the manager's game object is disabled, the manager will also stop working.

    I'd recommend using a bool variable for this, unless you actually want to use different values here. A bool is true or false, so that's the usual thing to use for toggling something on or off.

    A float variable would be if you e.g. want to display the NPC when the value reached a certain amount, e.g. if it's higher than 5.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Does that mean that instead of adding a Game Object Manager to an npc_green, the Game Object Manager will be added to an empty Game Object?

    If the type is Boolean, is the condition described above appropriate?
  • Exactly - add an empty game object to the scene, add the Game Object Manager component and set up your conditions.
    The manager will handle turning the NPC on and off for you.

    In case you need to do this for multiple game objects, a manager can also handle multiple game objects (with the same conditions), or you can add multiple managers to the empty game object.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.