Forum rules - please read before posting.

What is the best practice to carry character changes across scenes

edited April 2019 in Technical Q&A

In my game, the player (and possibly NPCs) will have changes in some properties such as speed, and some animator state clips would change according to the game progress.

What would be the best choice to keep the characters's changes across scenes? I hope to avoid assigning lots of variables and check them in every scene changes.

I tried a few mthods but all encounter some difficulties:

  1. Using DontDestroyOnLoad in characters, but then how can I drag the characters into the actionlists or public variables in the next scene?

  2. Changing the prefab in the Default Character settings, and remove the Player character in the scenes. But in this case I cannot get the cinemachines cameras to follow the player dragged by the prefab..

Comments

  • Changes made to a persistent player will survive scene changes - so long as you don't have a local player instance you should be fine there.

    If you are using a Cinemachine camera, you may need a simple script to get the CM camera to refer to the Player for it's "Follow" / "Look At" Transform when the scene begins. The scene's current player Transform can be referenced in script via:

    KickStarter.player.transform;
    

    As for NPCs, it may be worth adapting this script, which allows for the creation of global Containers, to work for NPCs. Instead of surviving scene changes (which will be difficult for the save system to keep track of), you instead have a copy of the prefab present in each scene, and sync their values when a scene begins.

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.