Forum rules - please read before posting.

Restore deleted character at runtime

edited August 2024 in Technical Q&A

Hi!

Could you please tell me if it's possible to put a deleted NPC back into the scene at runtime?

Due to unexpected behaviour, a character was accidentally removed from the scene using 'Object->Remove' action. Now I'm trying to undo the consequences. When I add the NPC back using 'Object->Add' action called in 'OnLoad' action, the prefab is added to the scene, but it doesn't return to multiple actions (walk to point, check component variable, etc).

All the 'retain in prefab' flags are checked, there's 'Remember NPC' component, etc.

Maybe there's an action to update all object references in the actions?

Comments

  • Due to unexpected behaviour, a character was accidentally removed from the scene using 'Object->Remove' action

    Is this to say you can't replace this with an Object: Teleport Action to move the character out of view?

    Maybe there's an action to update all object references in the actions?

    This will happen automatically if the scene-based Actions reference a prefab, rather than an object in the scene.

    If you update the Actions to reference the NPC prefab, you should find that they all list the prefab's Constant ID value. This'll cause them to search for an object with this value at runtime - meaning so long as the NPC is present again, they should work.

  • Is this to say you can't replace this with an Object: Teleport Action to move the character out of view?

    I should have used Teleport or Change Visibility, yeah, but I thought this NPC won't be necessary anyway at the point of deletion. But somehow for unknown reason it was deleted early, I guess there's some flaw in sequence of my actions =).

    This will happen automatically if the scene-based Actions reference a prefab, rather than an object in the scene.

    Oh, I got it! I dragged prefab to hierarchy from the project, and then dragged character from the hierarchy tree to the action, and there wasn't constant ID at the action. But now I dragged prefab directly from the project to the action, and constant ID appeared! Thanks a lot!

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.