2D Animated Sprite Not Showing When Spawned

I’m working on a prototype for a little 2D where multiple players can kill each other and then they respawn 3 seconds later. I currently have 2 prefabs for the player game objects, one set up to player one and one for player 2. When one player is killed, their game object is destroyed and a new version of their object is then spawned from a prefab. The problem is that when the object is put into the scene, it doesn’t show up on the camera. If I switch over to the scene inspector, I can see the object and have confirmed that it responds to inputs, and all the components are present including the animator. I have also tried to achieve the same ends by simply deactivating that game objects drawing and collision functions, waiting three seconds, changing it’s transform position and then turning everything back on, but I ended up with the same results. The current code that I am using to spawn the prefab is simply:

GameObject respawnObj = (GameObject) Instantiate(respawnPrefabs[count], position, transform.rotation);
where respawnPrefabs[count] contains a reference to the prefab to be spawned, position is the position pulled from a respawn point.

Any insight into what is causing this would be a great help, thanks.

“deactivating that game objects drawing and collision functions”

can we see those functions?
Is there a culling mask on the camera?
Do the objects have a sprite renderer?

Here is a screen shot of the functions currently attached to the game object. It does indeed have a sprite renderer and the culling mask on the camera is set to everything (default 2D project settings). The weird thing is that spawning a static sprite object like a bullet works fine and it shows up. I can’t find any settings between the two other than the animator.

1748737--110491--UnityCameraBehaviors.png

Oh, I see. The drawing and collision in this case aren’t “functions”. You have a renderer and collider “component”. That’s an important distinction (just an FYI for the future).

Is the image you posted from an object that was visible? If so, can we get a screenshot of one that is not visible? Whats the transform position and rotation of the spawn game object?

Yes, this is the settings of the object when visible. Attached is one in which it is not visible.

  • And I just noticed this and I am kicking myself for not picking up on it earlier. Thanks for the feedback Mike. I figured I should leave this thread up just in case anyone else runs into this problem.

Solution: The spawning Z position was the same as the Z position of the camera, placing the object outside of the FOV.

Yep! That’s why I was asking what the position of the spawn object was :slight_smile:

Glad you got it.