Forum rules - please read before posting.

Hello and question about character switching

edited October 2014 in Technical Q&A

Hello everyone.

I have been evaluating AC for the last couple of days and I have to say I’m very satisfied with its capabilities and extensibility.

I’ve got some newbie questions for you.

We have multiple player characters in our game so I’m trying to create a character switcher interface. I want to do it exactly as the manual explains and have NPCs for the inactive players and when I click on the switch interface transfer control to that character.

My problem is the case when the character I want to switch to is in another scene. The “Appear in Other Scene” option for the new player just displays the character at the player start point, and it seems that after the scene is changed the action list stops so I cannot handle it further.

I think it will require some custom code but I thought I should ask first 

What would you think would be the best way to do it?

I have thought to have all the game rooms in one big scene so I can switch normally and then change the camera to the current player. I don’t really want to go this way because it will probably hinder performance and also it will not allow for different people to work on different scenes.

Another option would be to:

1. Save current player’s coordinates

2. Teleport player away

3. Bring the current players npc to the saved position

4. Switch player to the new character (use “in other scene”)

5. have some code that runs on scene change where if both the player and his npc are on the same scene the npc goes away and the player moves in his position.

Do you think that would do it? Would it appear seamless?

Another (unrelated) problem that I have is this:

When I use the Object->Add  action in an ActionList asset,  if I choose an object that is not on the current scene and leave the inspector on the action list as I run the game, it only works for that run. After that, the gameobject to instantiate parameter is removed from the action and is replaced with (None). If I have the actionlist editor and inspector closed then there is no problem. Could this be a bug? I'm running the latest versions of both Unity and AC.

Thank you in advance

Comments

  • edited October 2014
    Please place questions in separate threads next time - it'll make them easier for me to answer.

    Player switching
    First of all, keep your scenes separate.  AC should allow you to work in different scenes - if it doesn't, that's a bug and will be fixed.

    Generally, you should check the "Restore position" checkbox when using the Player: Switch Action.  AC will store the current player's position (including scene), and load the new player's position (including scene).  If it's the first time this new player has been called, no data will exist - so you can use the If first time in game settings to set initial values.

    When you choose Appear in other scene, that will be the end of the ActionList (if the scene is indeed different to the current).  However, you can use the Player: Check Action in the new scene's Cutscene On Start to determine the current player, and place accordingly.  (You may need to have a Boolean check here to only perform this once)

    Object: Add Action
    Have you placed a ConstantID script on the referred GameObject?  When dealing with assets, you generally need this script - it's used to store a unique reference that works between scenes.
  • Hi Chris, thank you for your reply and sorry about the wordy questions. 

    About the Add action, yes I have the ContantID. It appears that if I leave the actionlist inpector or editor open it checks the scene, doesn't find the asset and removes the parameter. However this might be due to my general noobiness with Unity in general. I will try to recreate the problem in a new project and I will post results.

    I read on another thread that having hotspots inside prefabs can cause problems. I have a hotspot inside every npc prefab so that it moves together with the NPC. Could that be the cause of the problem and if so is there another recommened way to do that?

  • edited October 2014
    You don't need to merge NPCs with Hotspots - simply attach the Hotspot script to an NPC, and it'll work.  See any of these tutorials to get your Characters set up properly.  The "Brain" NPC in the 3D demo is also in your Adventure Creator folder for you to check out.

    As for the Add Action, a couple more things to check:
    1) That the object you're referencing is a prefab, not a scene object
    2) That the Constant ID script Inspector has "Retain in prefab" checked.
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.