Animation appearing in scene but not in game

I have this animation I’ve created for when the player’s y position goes below a certain value. It displays the word ‘Dead’ on the screen which increases in size. When testing this it works perfectly in the scene, but won’t appear in the game view? The attached screenshot shows how the animation appears (and works at the correct time) in the scene view, but not in the game view. Could anyone help as to why this would be?

1 Like

hi;
i think the reason that u can see it in editor and not in game window is the Z position of the sprite ;

try to change the Z value of transform position ;

It may be that your “Dead” Sprite is in behind the camera so it won’t be rendered. Click that little button in the editor above the scene view which says “2d” and you will see your scene in 3d. This way you could set the Z axis properly.

@Cuttlas-U @StevenUnu
Thank you both for your replies, I had already tried adjusting the Z position of the sprite so unfortunately that is not the fix. Maybe it’s something to do with my code:

public Transform playerPos;
    SpriteRenderer sr;
    Animator anim;


    // Use this for initialization
    void Start ()
    {
        anim = GetComponent<Animator>();
        sr = GetComponent<SpriteRenderer>();
    }
	
	// Update is called once per frame
	void Update ()
    {
	    if (playerPos.position.y <= -9)
        {
            sr.enabled = true;
            anim.SetBool("isDead", true);            
        }
	}

I literally just found the fix, I tried ticking ‘Apply Root Motion’ on the animation component and that seems to have fixed it. No idea why at all but it seems to work. Thanks for all your suggestions!