Forum rules - please read before posting.

Player Switching with custom player controller problem

Hi im kinda new with AC but getting the hang of it
working with the invector shooter 1.1.5 and having a couple of issues
I follow this tutorial  for Player Switching https://adventurecreator.org/tutorials/switching-player-character-mid-game
but in the moment when the player the switch has to happen  the player just dissapears but the game still running
All the players have the invector ac link and the player scripts in order. I follow step by step the tutorial i don't know what is  the problem this is the console error

GameObject vThirdPersonCamera was not saved because it does not have a 'Constant ID' script - please exit Play mode and attach one to it.

 -> AC debug logger
UnityEngine.Debug:LogWarning(Object, Object)
AC.ACDebug:LogWarning(Object, Object) (at Assets/AdventureCreator/Scripts/Static/ACDebug.cs:29)
AC.Serializer:GetConstantID(GameObject) (at Assets/AdventureCreator/Scripts/Save system/Serializer.cs:165)
AC.MainCamera:SaveData(PlayerData) (at Assets/AdventureCreator/Scripts/Camera/MainCamera.cs:1828)
AC.SaveSystem:SavePlayerData(Player) (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:966)
AC.SaveSystem:SaveCurrentPlayerData() (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:946)
AC.ActionPlayerSwitch:Run() (at Assets/AdventureCreator/Scripts/Actions/ActionPlayerSwitch.cs:95)
AC.<RunAction>c__Iterator2:MoveNext() (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:342)
UnityEngine.MonoBehaviour:StartCoroutine(String, Object)
AC.ActionList:ProcessAction(Int32) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:306)
AC.ActionList:BeginActionList(Int32, Boolean) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:274)
AC.ActionList:Interact(Int32, Boolean) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:185)
AC.ActionList:Interact() (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:154)
AC.AC_Trigger:Interact(GameObject) (at Assets/AdventureCreator/Scripts/Logic/AC_Trigger.cs:71)
AC.AC_Trigger:OnTriggerEnter(Collider) (at Assets/AdventureCreator/Scripts/Logic/AC_Trigger.cs:79)


And having another problem when the player dies this one i have a video
https://www.youtube.com/watch?v=aVm_5rWPAiE

I aprreciate any help 

Comments

  • Welcome to the community, @Kendall.  Which AC version are you using?

    The Console message is not a bug, but a warning that should be followed.  Just attach a Constant ID component to your vThirdPersonCamera object in your scene.  It's not related to the player-switching however.

    As you are using custom scripts, we will first need to determine if they are interfering and causing the problem.  Remove anything except AC scripts (you can do this in a separate duplicate project to test with), and get it working when only AC is involved.  If you have trouble in this case, please share details of how/when exactly you switch player in the form of screenshots of your ActionList and Settings Manager, as well as any messages that appear in the Console.  Once the problem lies with the fact that additional addons are involved, please share more details about exactly how those addons are integrated into your project.

    As far as the player "dying", AC doesn't have a concept of characters being killed - so this'll be down to your Invector integration.  When the player dies, is he being removed from the scene?  If so, you'll either need to prevent this from occuring (so that the same object merely resets their position), or call AC's ResetPlayer static method manually after they have been removed.
  • hi thanks for respond i made the test and yes the player swap works fine 
    with not any other add on instaled. So is positive is problem of AC with the invector controller. I made some experiments 
    So i can make the player can change from the one with the invector controller
    to the tin pot prefab character made enterely with AC.
    But i can't make an Invector charater switching to another Invector character
    any idea how to fix that

    thank you
  • Which versions of AC and Unity are you using?  Please be sure to try the latest version of AC.  Do any error messages appear in the Console?

    What happens exactly at the moment the switch should occur?  Does the invector player get removed from the scene?  What change occurs to the Hierarchy?  Please provide as much detail as you can - since you are using a third-party asset together with a custom script to connect it with AC, it is a problem unique to your project - so I can only go by the detail you give me to give advice.
  • i using the v1.62.2  no errors pops up in the  console   and yes the invector player instance  gets removed from the scene. In the  Hierarchy n the  DontdestroyOnload
    the persinstent engine and the Vgame controller are intact but the player instance is dissapear  
    i leave it a small video
    https://www.youtube.com/watch?v=Wu-xhNSvjyw&feature=youtu.be
  • You show the issue as you described, but not how it's occurring.  Let's see the Action you're using to switch player, your Settings Manager showing both player prefabs, and the Inspectors of the two player prefabs.
  • I can't see any issue from that - you'll have to PM me a project for me to test with.

    To keep filesizes minimal, you can duplicate the project and remove any unnecessary assets (AC demo folders included), and keep only the one scene to test with.
  • Hi Chris and Kendall,
    i've the same exactly issue of Kendall.
    I use the last version of AC and INVECTOR SHOOTER.
    Have you find a solution? Thanks!

    Paolo :)
  • I've already tested following your lesson and all works.
    Also, if a try to switch from a PLAYER INVECTOR to a PLAYER AC all works.
    But from a PLAYER INVECTOR to a PLAYER INVECTOR the first player desappear but the second player don't be instantiate in the scene. If i push the third time the button's switch the first player is instantiated correctly. Thanks
  • IIRC the issue @Kendall was having was a problem with Invector, not AC.  Invector deletes any new instance of the player prefab, if an instance for it has already been set internally, on line 30 of vThirdPersonController.cs.

    I've written a workaround script for you which should mitigate it here: http://pasteall.org/907908/csharp

    To use it, paste it into a new C# script named "InvPlayerFix.cs" and attach it to a new GameObject in your scene.

    You should, however, contact the author of the asset in question in case a more suitable fix is necessary.

  • Many thanks, Chris! Today i'll try It! 😊 I love Adventure Creator! ❤️
  • Wonderful, Chris! Your script work perfectly!
    I'm so happy! :)

    There is a little change to make in the header for work correctly in my version:

    using Invector.CharacterController;

    i've change the line in:

    using Invector.vCharacterController;

    Many Thanks!
    Paolo :)
  • edited November 2018
    Hi, Chris. Your script it's ok but now there are a new strange thing.

    When i come from the scene menu and i select the "Scene 1", the default player  don't move. In the Console i read: "There is already a virtual axis named Vertical registered." and "There is already a virtual axis named Orizzontal registered."

    If i play the "Scene 1" directly, without the scene menu all work.
    Do you have any idea? Thanks.

    ***UPDATE***
    I've try to create a new empty scene menu (whitout AC structure folder) and i have placed a button that load the SCENE 1. In this way work. Obviously, I would like to use a AC scene for my scene menu.
  • That is not an AC message.  The full Console message will reveal its source via the stacktrace, but you haven't posted any detail about the way your scenes and project are set up that might give a clue as to what's going on.
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.