Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Discussion Procedural NPC informaion

Discussion in 'Scripting' started by cidmodder, Jun 26, 2023.

  1. cidmodder

    cidmodder

    Joined:
    Dec 9, 2010
    Posts:
    21
    I am making an RPG game that is procedurally generating the world, including the characters in it. The characters are all going to be associated with a specific location and have various stats including things such as their job, an reference ID, and typical RPG stats. There will be an unknown number of NPCs that will change based on certain input conditions and these stats can all be altered by the story and the choices the player makes throughout the game so I need to be able to read and write the data in a efficient way that makes it easy to change when I don’t know exactly where it may be in the array.

    Any suggestions on good places to start? Most of the discussions I’ve already gone through point to JSON and I’ve played a little with lists doing this so far but haven’t made something that functions as intended yet.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,561
    Yeah! Make a single data structure, perhaps a ScriptableObject, give it a "Name" field and then one particular attribute you have in mind, perhaps their job.

    Make a preliminary UI to present that and interact with it as you envision, only relating to the two traits above.

    Iterate upwards from there... GO!
     
  3. cidmodder

    cidmodder

    Joined:
    Dec 9, 2010
    Posts:
    21
    Thanks for the reply! Pardon my ignorance but I am hitting a roadblock with what you’re describing with scriptable objects. I read through the manual part and I’m not quite following how exactly it stores the data so I can access it again when I need to say have the player run into John smith again after they have already met.

    Do you know of any good tutorials for scriptableobjects that could help me understand the basics of it?
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,561
    Google the above, there's plenty to choose from.