Search code examples
unity-game-engine2dgameobject

Player game object vanishes on play


So im trying to put a game object into my game using the robot boy prefab from the standard assets on the asset store.

However, although he shows in the game view after putting him into the scene, as soon as I try to play the game he vanishes. Ive got the sorting layers etc right as far as I can see. Not sure why this is happening?

See attached for examples

enter image description here


Solution

  • Click on the player GameObject in hierarchy while in playmode and go to scene view and press F key twice to see where it is hiding. If you can locate it within your level setup Most probably it is hiden behind something because of sorting layer. Change the sorting layer for player to bring it front.

    It might not be unvisible due to sorting layer because there is a case when rigidbody plays weird and teleports player to far away from the camera. Or it might be constantly falling down because of improper collider configuration. Check its transform component specially position if it is constantly changing or ifs different than what you had before playing the game. And check the scale as well. It might be set to (0,0,0) and the player is appearing invisible

    Hope this helps.