Enemy not being displayed on the game window

when I run the game I can see the enemy moving on the scene window whereas its not visible on the game window

Maybe it’s because the enemy sorting layer is the same as the background sorting layer?
This may cause some glitchy behavior.


its different

So it works now? Or does the enemy disappear when you play?

it disappears

It could help to add a different sorting layer to the background. Or alternatively remove any existing sorting layers and replace it with the default one.
Try to set the order in layer for the background to 0, and the order in layer for the player and enemy to 1.

sorting layer As in?

If your object has a Spite Renderer attached, in the inspector, you should see something called “Sorting Layer”. If you don’t, then click the drop-down called “Additional Settings”, it should be there. The sorting Layer should be “Default”.
image33
You can change the order in layer right under.

You can also add a new layer in the top-right:
edit layers

There you can add your own custom sorting layers:
sorting layers

The order in layer is the order that sprites will appear in.
A sprite with an order of 1 will always be on top of any other sprites lower than 1.

For example:
There are two objects: Object1 and Object2.
If you want Object1 to be on top of Object2, make sure that the order in layer of Object1 is greater than Object2.
If Object1 has an order in layer of 1, and Object2 has an order in layer of 0, Object1 will be on top because 1 is greater than 0.

still not working😩

Maybe it has something to do with the camera.
Go to Canvas and set it to Screen Space - Camera,
then drag the main camera into the “Render Camera”.
See if this fixes the problem.

Hi Isha,

Is the z-position of the background set to 10, the z-position of the camera to -10 and the z-position of the other game objects to 0?

yeah its already set to the above values

Could you please share screenshots of what you see and have in Unity? The Inspector of the game objects (background, camera, invisible enemy) would be interesting for us.

background

camera

enemy

Thank you. Your screenshots look fine, and the enemy is visible in the game window.

Just to ensure that I understood your problem correctly: The enemy disappears when you start the game?

If so, check the positions of the Path (0) game object and its children. Their respective z-position must be set to 0, too.

yes its working properly now thank you😁

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms