Forum rules - please read before posting.

Problems with asset lists targeting multiple prefabs

Very confusing title, sorry. best if i explain.

Game has 4 possible players, we swap between them.
So as to not spend all my time tweaking unique cameras and things on all 4 players I tried to have a camera prefab. As the game is 1st person (mostly) I have to have the first person script on the camera, and make the camera a child of the players.
The problem with this is that as soon as I Prefab the Players, the camera becomes part of THAT prefab, and if I THEN update ONE cameras settings, it doesnt now populate to the 4 players seperate cameras, cos they think they are part of the player prefabs.

Why the title. Because. In addition I have a torch in the inventory that the players can turn on. There is an Asset list that does this (as will as other stuff, like putting a torch model in the hands of the players, adding and removing from inventory etc.) This asset list also gets confused.. even though there is only ONE of the PlayerCam (with torch as child) in teh scen, it now references other versions.

Now the normal way I would solve this, would be to NOT have the camera be a part of the player at all, have a copy in the scene (every scene actually I have multiple) and just drag it around with a follow script (done in PlayMaker) Except... that AC complains that for the first person setting to be set, the player must have the script on it...

Is there a nice simple way around this?

Comments

  • edited June 2016
    If you're talking about nested prefabs (prefabs within prefabs), that's something Unity devs have been asking for a long time.

    If you're using AC's first person mode, definitely go with what AC wants - i.e. having the script on the Player.

    AC's ActionList Assets refer to scene objects by Constant ID number.  If one doesn't exist and it needs to, AC will generally try to assign one automatically.  When the ActionList runs, it will look for the object in your scene that has a matching ID, however you can manipulate this by changing the number manually.  For example, if you wanted two different cameras in two different scenes to be affected by a Camera: Switch Action placed in an ActionList asset, you could make sure both cameras have the same ID number, and then the same Action will work in both scenes.

    The same technique works for player prefabs too - the only thing you need to be careful of is that only one object with a given ID number is in the scene at any one time.
  • I see, so using this method (asigning a Constant ID number manually) I can do this? Thats excellent.
    To summerise.
    A torch, that is a child of the camera that exists on 4 different players is given a FIXED ID manually.
    The actionlist that turns this torch on and off, targets that torch.
    And yes, only one player needs to be in the scene at a time.
    (This IS a challenge that I was expecting anyway, of course, when NOT a player, they become NPCs... but thats an issue anyhow, Ill be spawning in an NPC copy when that happens)

    Thanks.. will check this out!
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.