Before asking the question I just like to thank @gamingislove for update Makinom to 2019.3. The more I use it the more I love it really easy to think in terms of game design than other visual scripting assets.
And I still learning Unity and Makinom so anything I don't know please tell me.

So my question is:
(1) How can I get/set the new Object variable ID every time I spawn a prefab for this spawned prefab?
Either via a script or a schematic or any other method.
I don't know how to access Object Variable ID to get/set a new ID for spawned prefab via schematic.
I know Local Object variable is like a unique object ID and it really good for a temporary object but I will not ask this question when it can be saved but it can't and I need to save every single object of the same prefabs in the scene with its own Object variable ID.

(2) If the first question doesn't have an answer then how can I save an object in the scene with its own variable for the same prefabs when I spawn it?
Take Object position as an example, when I save the game I want every object of the same prefabs to be at their position when I loaded.
Right now I don't know how to do this besides manually make every object in the scene have unique Object variable ID. But I can't do that when in-game with newly spawned prefabs.
  • edited March 22
    Glad you like Makinom :)

    1) Hm, I don't think this is currently possible - while you can generally change the object ID via the objectID field of the component (e.g. using a Change Fields node), this will be too late, as the initialization already happened at that point and it doesn't change the object ID of the variables.

    What's your use case? E.g. setting random IDs for spawned prefabs will save their variables, but you'll probably not be able to retrieve them when respawning them ...

    2) Hm, I'd recommend using custom save data for this. This'd allow you to save positions and data from spawned prefabs with save games (including local object variables).
    Post edited by gamingislove on
    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!
  • My use case like this:
    Instead of reloading and respawning NPC every time the player loads the game, I want every NPC in the scene when saved have their object variable remain like that when loaded.

    So yes I need spawned prefabs to be saved and you said I'll not be able to retrieve them what does that mean exactly. Can you tell me an example?

    And you recommended using custom save data and honestly, I don't know how to do that in code because I don't even know how to code just look at it make my head hurt and if I use 3rd party asset like Easy Save, for example, how do I integrate it with Makinom?

    But at first, I thought if somehow I could make every spawned prefab have a unique ID then I only have to save object position in vector3 variable then when loaded I will just set object position to that vector3 variable on start.

    Or I think wrong about how prefabs should be saved and loaded? Because you said to set a new Object Variable ID for spawned prefabs is not possible.

    I'm sorry to bother your time with noob questions like this because I still have no idea how objects and prefabs should be saved in Unity and Makinom.
  • Are your NPCs actually spawned via e.g. a schematic, or are they already placed in the scene? And if they're spawned, are some of them sharing the same prefab, or do all have their individual prefabs?

    If each NPC has their own prefab (can also just be variants) with their own unique ID, you can easily do this with built-in systems. E.g. saving/loading the position would just be storing the position into the NPC's object variables and having an auto machine that uses the stored position.
    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!
  • Thank you! Clarifying for me so NPCs already placed in the scene and individual prefabs just have a unique ID then it is easy like you already said.

    But I'm still having a hard time trying to find out how I'm gonna saved the same prefabs spawned via schematic.
  • If it's just remembering prefabs, you could store their positions in a global Vector3 variable list and use an auto machine to spawn them again when reentering the scene.

    However, if you also want to save their object variables, I'm afraid you'll have to use custom save data for that.

    Alternatively, you could commission a feature for this, if you're willing to spend money on it :)
    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!
  • That will do and having an illusion of NPCs being saved. Thank for your help!

    Of course, I will support Makinom in the future when my game also got supported.

    But for now, I happy to work with what I got. My finances are still a problem for me right now so I can't support you yet.

    Just let you know by update Makinom, you already do me a great deed but as I said in the 2nd line so that also depends on my game or maybe if the situation of my finances gets better.

    So thank you again! Stay safe and remember to wash your hand.

Sign In or Register to comment.