Forum rules - please read before posting.

Player doesn't move or animate when returned to previous scene

Hello, I'm seeing a strange behaviour with the Player script.
The player gameobject is a prefab with the player script attached and added to different scenes. Scenes are loaded from script using AC.KickStarter.sceneChanger.ChangeScene(). When a new scene is loaded for the first time everything works fine but when it's loaded again (return to the previous scene from current scene) the player doesn't move or animate but just rotates in the move direction. At this point I noticed that the mecanim parameters defined in the player script are empty and the walk and run movement floats are set to 0. This doesn't happen with the NPC characters.
I'm not sure if it's a bug or if I'm doing something wrong.
AC version - 1.71.4
Unity - 2019.4.0f1

Comments

  • edited August 2020

    Welcome to the community, @Roy9720.

    Can you share the exact code you're calling to change scene? The ChangeScene function has a few parameters that affect exactly what happens.

    Try also running a Scene: Switch Action from an ActionList to change scene instead - just so we can determine if that's doing something extra that your code will need to as well.

    When re-entering a scene, AC will load in data about that scene that was previously recorded - including data about any local Player it has. I expect this wouldn't occur if you removed the Player objects from the scenes and instead let AC spawn the Player automatically from the Settings Manager.

    Do you get any related Console messages at this time?

  • Thanks @ChrisIceBox.

    AC.KickStarter.sceneChanger.ChangeScene(0, saveRoomData = false); this is the exact line of code I used to change scenes.
    I tried doing a scene switch from a cutscene and everything worked fine. Then I also added the player prefab to the settings manager with the player objects still in the scenes and there was no problem. Finally I changed the code to AC.KickStarter.sceneChanger.ChangeScene(0, saveRoomData = true); because scene needs to be switched from a UI button click and it worked fine then too. So I'll stick to this one. Thank you for all the solutions.

    But I still don't understand how setting 'saveRoomData = true' fixed the problem as there aren't any 'Remember' scripts on the player or NPC's.

  • I still don't understand how setting 'saveRoomData = true' fixed the problem as there aren't any 'Remember' scripts on the player or NPC's.

    AC will save non-Remember data related to the Player automatically, such as position, etc.

    Then I also added the player prefab to the settings manager with the player objects still in the scenes and there was no problem.

    The Player prefab assigned in the Settings Manager will be overridden in any scene that has its own Player object in the file - they'd have to be removed for it to make a difference. However, if things are working now, perhaps best to just leave as it is.

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.