Forum rules - please read before posting.

NPC/HotSpot : separate graph from logic

edited June 2014 in Engine development
Hi, I would like to know if it's possible to separate the graph from the logic for NPC and Hotspot. For example, having a hierarchy like this :

ParentGameObject : MyNPC
ChildGameObject : Logic (with NPC, Hotspot scripts,....)
ChildGameObject : Graph (the fbx)

Because when I update my fbx, all scripts are erased.
I saw something like "spriteChild" in code but this is enabled only in 2D Mode



  • No, but your scripts should be getting erased like that.  Are you prefabbing your NPC properly?  Be sure to place it in your Assets folder after creating it in the scene.
  • Of course I'm placing it in my Asset folder.
    Did you mean "should'nt" in your answer ?

    Because actually I have a gameobject with graph and scripts (like NPC, Hotspot)in my folder "Assets/Prefabs". When I update my fbx, I drag & drop the fbx file in the prefab Object, a window appears saying "Possibly unwanted Prefab replacement" and if I click "Replace anyway" all scripts in my gameobject are erased.
    If I click "Don't Replace" graph is not updated.

    So if I have to update my graph, I have to replace all my scripts...which is not productive.
  • It doesn't sound like you're using Unity properly - you shouldn't have to drag your FBX onto the prefab.  If the prefab references the original FBX model, updating the separate model file will update the prefab without affecting anything else.  That's the way Unity's designed to work!
  • No, if the hierarchy of your fbx is changed (like adding or removing an object inside it), the prefab who is referencing the fbx won't take this changes.

    Look at Unity's forum, there is a lot of posts talking about this.

    So to override this thing you have to drag & drop the fbx in the prefab to correct the link and take all this changes. But doing this will erase all scripts inside the prefab.
  • Just a question pysnoo...

    1º Instantiating the object on scene...
    2º Updating the object (fbx) on scene instance, so it's not a intance anymore
    3º Saving the scene object onto the prefab, replacing it...

    gives the same result?
  • By instantiating the object on scene, you mean drag and drop your fbx (or prefab ??) in hierarchy or by code ?

    Because updating the object on scene instance means drag and drop your fbx in your scene for me.
    So yes, if you drag & drop your fbx in your scene and then make this a prefab, the prefab will be good. But if your fbx changed (like adding an object to it in max or whatever), your prefab won't take this change.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.