- Home /
2D - FollowCam causes player sprite to disappear
I'm using a simple script attached to the camera that causes it to track the player's movements exactly, keeping the player sprite in the center of the screen. Here's all the code that makes it work:
public GameObject player;
void Update()
{
if (player == null) return;
Vector2 destination = player.transform.position;
transform.position = destination;
}
It works, but it causes the player sprite to disappear from view when the sprite object is attached to the script. When I remove the object, the sprite appears as normal. What could be causing this?
Comment
Your answer
Follow this Question
Related Questions
Sprite facing multiple cameras? 1 Answer
How can I make a layer black? Unity 2D 1 Answer
Unity 2D: Pixel Perfect Camera + Resolution Help 0 Answers
2d camera bug 2 Answers
Any way to make Animation.Play take effect immediately? 2 Answers