- Home /
Sprite not being rendered on play mode but it appears on the editor.
So in my 2D game I have a prefab that I use as a base for all my player ships called PlayerShip, each ship has a main body and a gun as you can see:
Both of those gameobjects have a sprite renderer attached to them, the PlayerShip has one for the ship, and the gun one for displaying the gun of the ship, like so:
PlayerShip gameobject Gun gameobject Then I just create some prefab variants that give those sprite renderers their correct sprite. The problem occurs with the first ship I try putting a sprite for the gun, it shows above the ship on the editor but when I hit play the sprite doesn't even appear:
Editor view Play mode view
I searched online for this but all the answers I could find where about the camera transform, or the sorting layers, my camera transform Z component is -10 at runtime and as you can see in the screenshot the Gun transform Z componente is greater than that so I don't think that's the problem, also heres how my sorting layers are implemented: Any clues on to what is going on?
Answer by elrohirgt · Jan 04, 2021 at 03:12 PM
Solved it, turns out in another script I was using the LookAt function of the transform, so because this is a 2d game an object being rotated so the forward vector points towards a side disappears, fixed now.
Your answer
Follow this Question
Related Questions
Pixel art sprites being slightly distorted 0 Answers
Arrays? ↓↓↓↓↓↓↓ 2 Answers
Why are my sprites wierd in Unity? 0 Answers
Low FPS because of changing sprites 2 Answers
How to set sprite size in pixels? 2 Answers