Forum rules - please read before posting.

Is there a way to add a character to the scene multiple times and have them follow different paths?

Hi. In my game there is a section enemies patrol in a maze. I made a prefab for the enemy but try not to make 10 prefabs for 10 same enemies. Is it possible to add the same NPC prefab to the scene but assign them to follow different patrol paths? Thanks.

Comments

  • I don't see why not - have you tried it?

    You'll have to make sure that any ConstantID / Remember scripts they have are unique to each instance - so that the save system can differentiate between that.
  • edited November 2018
    I tried but since the enemy object is from the same prefab, when I use the Object > Add action they always result in the same Constant ID. Are there ways to change that?

    If I use scripts like object.Instantiate, I don't know how to reference that object in the Object > Add action editor.
  • See the Manual's entry on the "Remember Transform" component in the "Saving scene objects" chapter - you need to assign the prefab's Constant ID value in the Linked prefab ConstantID field.
  • Thanks, I successfully make copies of the NPC with new Constant IDs.

    But how may I assign those NPCs to follow a path or in other actions?
  • edited November 2018
    When Unity 2018.3 is out, you'll be able to create prefab variants, so that you can make 10 copies of the prefab and have them all link back to the original.

    In the meantime, it may be that you have to rely on ActionList parameters so that you can set the "NPC to move" etc fields to GameObject parameters - and then update those parameter values at runtime, likely through script.

    It'll be much easier to have them in the scene file - I don't know what your needs are, but I'd recommend not spawning them in at runtime if you can help it.
  • Ok I will wait til 2018.3
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.