Hello! In my current Unity project, I'm encountering an issue with the SpriteRenderer not displaying a selected sprite despite being in a valid configuration. There are a number of moving parts to this issue, but I've chosen this forum as it ultimately results in a rendering failure and I cannot discern a precise cause.
Disclaimer: I'm a Unity newbie. This is my first Unity project and I appreciate I am probably rather lacking in detailed knowledge on these components and how they interact with Unity's internals. I have made a best effort to research this issue online, troubleshoot it myself, and ask for help in spaces dedicated to the multiplayer library potentially involved (details below), but I apologise in advance if I use nonstandard terminology or need extra explanation. Please feel free to ask me for any information that may be of benefit for making useful suggestions.
The problem. The game is intended to be an MMORPG, and I have a configurable EntitySpawner which periodically instantiates Entity instances from an assigned prefab. The first time this "spawn" triggers, it usually (but not always!) does not exhibit any issues (if triggered in Update; see symptoms below.) However, upon the enemy being despawned or killed, and then respawned by the spawner, the new instance is usually (but not always!) not visible. This is despite all properties of the new instance being correct to the extent that I can verify, with all other functionality of the instance working correctly, and the SpriteRenderer sprite being correctly set, not occluded by other sprites, etc.
Networking. Being an MMORPG, there is a networking aspect to this: I am relying on the PurrNet package to implement my networking. Spawning the player character is done locally by the owning player and validated on the server, which works as intended; however, in this instance the new Entity instance is being spawned by the server. I cannot confirm whether or not this is a contributing factor but I would be remiss to not mention it. I have already spoken to their support channel about this issue, and exhausted all available suggestions.
Detailed symptoms list. Please find below a list of point-form details that may be of importance:
- No errors, logs or warnings appear which would be indicative of obvious bugs
- When the spawn function of
EntitySpawneris triggered fromLateUpdateorFixedUpdateinstead ofUpdate, the firstEntityinstance spawned has never rendered as intended, instead always experiencing the same issue described. - The sprite of the prefab is never modified by any script, and is already set in the prefab at compile time
- The
Entityinstance has an attached HP bar; this is not part of the prefab, and is spawned by a script in the instance upon spawning. This HP bar always presents correctly, even if the main sprite does not render.
Troubleshooting steps tried. Please find below a list of attempted troubleshooting steps:
- Disabling and re-enabling the
SpriteRenderer - Removing and re-adding the
SpriteRenderercomponent - Changing the sprite to be rendered
- Reordering components
- Modifying the Z coordinate of the associated
Transformto ensure it is not occluded or behind the camera - Changing the sort ordering of the
SpriteRenderer - Moving the instance to a position with no other sprites to ensure it is not occluded
- Disabling the
NavMeshAgentof theEntityinstance - Disabling the
NetworkTransformof theEntityinstance (a PurrNet module for plug-and-play position synchronization between clients)
Media. Following this main post in the thread will be some media of the game, displaying the issue I am encountering.
Any suggestions or pointers are appreciated! I simply don't know what else I can try at this juncture, and am hoping someone with more experience might be able to offer some pointers.