Forum rules - please read before posting.

Default Inactive Player Start or Array of "Previous Scenes"

Dear Chris and AC followers,
I'm tuning the last things about ENCOYDA and I've an issue.
Basically it's related with "PlayerStart" for my inactive player when using a Map. Everything works well when moving from one scene to another, but when I use my "map travelling", the inactive player is spawned in the same position as my active player (consider I ALWAYS have the two players on screen).
Some weeks ago Chris suggested me to teleport the inactive player when clicking on the map, even before switching scene, however, I cannot do that because each scene has a starting action which teleport my inactive player based on previous scene (this was done before the "follow across scenes" was implemented in the NPC following, so for me it's too late now to change that).
Meaning: I can't teleport my player before switching scene, because anyway OnStart of my scene the inactive player is teleported "based on previous scene" and since it's not finding the correct previous scene when using map, it simply spawns my inactive player to the Default Player Start (even if that is set to "Active Player Only").
So now I've 3 solutions:
1- very ugly: creating dozens of "PlayerStart" objects, one for each of the possible scenes my player can come from (but since it's for map travelling, this mean sometime creating 20-30 objects, which is just too long to do and not elegant).
2- Changing the "PlayerStart.cs" script to accept a list of "Previous Scenes", so the "Player Start" object is one, but rather than checking only one string of Scene Name, it goes through a list of them (even better if the list of Scenes are separated by comma on a single field, rather fan filling different fields).
3- Creating a "Default Inactive Player Start", similar to the "Default Player Start" for the active player (i.e. teleporting there if AC doesn't found anything better), but working for the Inactive one. This mean probably changing the "SceneSettings.cs" script...
What do you suggest? What's the fastest solution to avoid the issue I'm having?
Thanks a lot!

Comments

  • The PlayerStart component has a Limit by active field - set this to Inactive Players Only to have it only react to your inactive Player.

    But, it'll still take the "Previous scene activation" settings into account. The quickest solution would probably be to have a script that modifies that data to match the previous scene before AC initialises the rest of the scene:

    using UnityEngine;
    using AC;
    
    public class MatchPreviousScene : MonoBehaviour
    {
    
        private void Awake ()
        {
            GetComponent <PlayerStart>().previousScene = KickStarter.sceneChanger.GetPreviousSceneIndex ();
        }
    
    }
    

    Attach that to the PlayerStart you want to act as the default for your Inactive Player. While Awake should kick in before anything else, you can ensure it doesn't compete with any other Awake function by giving it a negative Script Execution Order.

  • Thanks a lot!
    Awesome as always!

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.