Forum rules - please read before posting.

Switching Player; Game Camera loses target

edited July 2014 in Technical Q&A
When I switch the Player character prefab in a scene the Game Camera’s target doesn’t update to the new “Player” in the scene, losing its ability to follow the player around. It looks like the “target” switches to the PlayerStart prefab, rather than the new Player prefab. Is there a step I’m missing?

Thanks!
Ben

Comments

  • I never used the switch player option, but I had a similar problem when I load a previous saved game, that the camera doesn't follow the player. I solved by adding a Constant ID script to the camera... maybe is not your problem but you can try this solution...

    It's also written on the manual:

    "The following is a general guideline for setting a scene up correctly for saving and loading:
    • All GameCamera objects that are used during normal gameplay (that is, not
    purely used during cutscenes) have a ConstantID script.
    • All Conversation objects with DialogueOptions that can change have a
    ConstantID script.
    • All Path objects that characters may be using upon saving have a ConstantID
    script.
    • If the active NavMesh can change during a scene, give all NavMeshes a
    ConstantID script.
    • All Hotspot objects that can be turned on or off have a RememberHotspot script.
    • All NPCs have a RememberNPC script.
    • All other GameObject types that are moved during gameplay (through it's
    Transform, not just Animation component) have a RememberTransform script."
  • Thanks for the input, 2finger! That is one of the first things I tried though, to no avail. I even tried switching cameras to see if the new camera would find the new Player prefab in the scene. Unless there's something I'm missing, the game camera seems to lose its target when you switch Player prefabs.
  • I will try to recreate this problem on my end.
  • I had a similar problem and although the thread is very old, maybe somebody else is having this problem as I did. In my case, what was happening seemed like the camera losing track of the player, but it was indeed the scene not grabing the right camera after the player switch. I solved it by adding a switch camera on every OnLoad. Not sure what is making the camera not grab the right one when switching players but this fixed mine. Hope this helps all the newbies like me out there!
  • I know it's been a long time since the question was asked but unfortunately I have the same problem. I have a camera attached script that uses GameObject.FindGameObjectsWithTag ("Player");

    The script can not find the player after the character switch.
    An clue to solve the problem?
  • A reference to the active Player at any time can be retrieved with:

    AC.KickStarter.player;

    This will update upon switching player, but if you're storing a reference as a local variable you'll need to re-assign it after the switch.
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.