Forum rules - please read before posting.

Script for setting the player?

Heya, I'm wondering if there is a script that AC uses that sets who the player is?
I'm basically running my own script on game start where:
-AC is turned off
-Another script loads the player into the game
-AC is turned on
-AC spawns its own player. Now there's 2 players in the scene and none of them can be controlled because my script is running on the first character, and the game sees this character as the player, but all of AC's player controls (and thus the movement controls) are on the second player. So I'm stuck.

I wanted to see if there was a way where the player could be assigned in script, so that when it's run and AC is turned on, the 1 character instantiated through script is the player and I'd be able to control it and move it around.

I hope this makes sense.
Thanks very much :)

Comments

  • It is possible to reset which player is active with the
    AC.KickStarter.ResetPlayer function, but the supplied Player parameter
    is a prefab that will get spawned - so probably not appropriate here.

    Is the Player you're adding to through script (before AC is turned on) an AC Player prefab?  AC attempts to auto-detect any Player in the scene by searching for Player components on objects also tagged as Player.

    It might be easier to have AC on at the start, and the player present in the scene file, and then disable each of AC's systems using the Engine: Manage systems Action until you're ready for it to run.
  • Hey Chris,
    I'm actually attempting to integrate Photon (risky idea considering AC is a single player thing, I know) but wanted to give it a try. So I need Photon to initialize the player first instead of AC.
    This is the code for it: 
    PhotonNetwork.Instantiate (player.name, spawnPoint.position, spawnPoint.rotation, 0);
    Player.name being the prefab, and the spawn points linking to the player start markers which work fine (the Photon player goes to the player start, but I don't have AC control over it-- instead the game spawns one that AC created and one that the script created)

    So was trying to think of a way to get the AC to instantiate the player through script. 
    Do you have any idea how to do it that way?
  • Definitely a risky idea!

    But in my own tests, AC recognises the player - which you can check yourself by ticking List active ActionLists in Game window? at the bottom of the Settings Manager.  In the current release, that will also list the active player.

    However, when adding any AC object to the scene through script, you also need to update AC's internal record of objects:

    AC.KickStarter.stateHandler.GatherObjects ();


    Try adding that after turning AC back on.
  • edited November 2017
    Heya Chris, got it working now, thanks! 
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.