Wrong cams get enabled when the 2nd player enters the game. Can’t seem to find out what I’m doing wrong.
1 Answer
1Btw. I personally use a seperate script attached to the player Camera which contains something like this:
function Start(){
if(!transform.root.networkView.isMine){
transform.gameObject.active = false;
}
}
Please wait for moderation
– whydoidoitSome parts of your code aren't well formated so i could look through everything but just a wild guess. Do you disable player 1's camera if player 2 spawns? If not you should do it. It's enough to disable the Camera Component and the Audio Listener Component of the Camera gameobject if you need the object for something else.
– ExTheSeaThank you for your reply, I have updated my question with pastebin links. Also the code inside is updated, if you could take a look. Thanks. Edit: I have updated the game demo with the new code.
– damagex443In your Player.js script you have this line playerCam.camera.enabled = true; which gets executed when networkView.isMine returns true and false. I don't know about your gameobject structure and also which camera playerCam is when networkView.isMine returns false but i think enabled should be false here.
– ExTheSeaThe Network.Instantiate creates a game object named Player(Clone) with a child camera object named playerCam. That one has the component SmoothFollow targeting the parent Player(Clone). The player object has the script Player.js with playerCam to child object. And there is a seperate empty game object that holds the script AvatarControl.js with the player Prefab.
– damagex443