- Home /
Camera deselecting dead players
Hello, so I got a problem where I have made an camera that zooms in and out when player 1-4 moves closer and further away from eachother. But my problem is that when I kill of for example Player1 i get an error that says "The object of type 'Transform' has been destroyed but you are still trying to access it". I know how to kinda fix it, you have to remove it from the list of camera targets. I was just wondering how you did that easiest with code or just in general while playing the game.
Answer by bpaynom · Mar 05, 2019 at 08:27 AM
In your Player component, or wherever you kill the player, you could get a reference to the script of the Camera which has that list of players, and access a new method like this one on your camera script:
public void RemovePlayer ( PlayerComponent player )
{
listOfPlayers.Remove( player );
}
Your answer
Follow this Question
Related Questions
Changing 2D URP Shadow Color 1 Answer
Calculating 2D Camera Bounds With Zoom 0 Answers
Stop main camera from zooming 2D 1 Answer
Camera movement in a pixel perfect 2D game, how to do it the right way? 0 Answers
Scaling giant images as 2D Sprite 0 Answers