Forum rules - please read before posting.

ResetPlayer problem

Hi,
I'm trying to instantiate a player through script as due to other scripts running it can't be in the scene until the other scripts have finished.

I have tried this:

else
{
AC.KickStarter.ResetPlayer(player2.name, spawnPoint.rotation);
AC.KickStarter.stateHandler.GatherObjects ();
}

But I'm getting this : "error CS1501: No overload for method `ResetPlayer' takes 2 arguments"

What is the correct way to do this because this is something I'm quite new to?
Thank you

Comments

  • Hi, just a bump, does anyone have any idea?

  • The arguments are incorrect. You can find the required arguments for any public AC function in the scripting guide. Those for ResetPlayer can be found here.

    Alternatively, you can enable player-switching, and start with an "empty" player, then use the Player: Switch Action to enable the proper player.

    It doesn't sound right that the Player should not be present, however. Simply hiding them from view isn't an option?

  • Hi Chris,
    I'm now getting the errors:

    "error CS1502: The best overloaded method match for `AC.KickStarter.ResetPlayer(AC.Player, int, bool, UnityEngine.Quaternion, bool, bool, bool)' has some invalid arguments"

    And

    "error CS1503: Argument #1' cannot convertstring' expression to type `AC.Player'"

    This was the line now:
    AC.KickStarter.ResetPlayer(player2.name, 1, false, spawnPoint.rotation, false, true, true);

    And these were the variables:

    [SerializeField] private GameObject player2;
    [SerializeField] private Transform spawnPoint;

    How have I messed it up this time? Lol

  • You're passing a GameObject's name as the first argument, whereas it's expecting a Player component.

    Define the variable:

    [SerializeField] private Player myPlayer;
    

    Then replace "player2.name" with "myPlayer" in your call to ResetPlayer.

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.