Hi! I’m currently following the TileVania section of the course. I found an error in my project but I don’t know how to handle it, I even don’t know what’s wrong honestly. So the error is: when my enemy hits the wall and has to move to the left its sprite disappears. It isn’t a problem with layers, its sprite is gone.
Please, help
Hi Nick,
Please note, it’s better to copy/paste your code and apply the code fencing characters, rather than using screenshots. Screenshots are ideal for displaying specific details from within a game engine editor or even error messages, but for code, they tend to be less readable, especially on mobile devices which can require extensive zooming and scrolling.
You also prevent those that may offer to help you the ability to copy/paste part of your code back to you with suggestions and/or corrections, meaning that they would need to type a potentially lengthy response. You will often find that people are more likely to respond to your questions if you make it as easy as possible for them to do so.
I hope this makes sense.
Is the z-position of the background set to -10?
See also;
- Forum User Guides : How to apply code formatting within your post
Hi Nina, thanks for the suggestions about the code. Yes, the z-position is set to -10
There is a message in the bottom right part of the screen in the last screenshot that pop-ups when the enemy tries to go to the left.
What message? Could you post it here?
Also check the z-position of the enemy in the Inspector when it disappears. According to your screenshot, it seems to be at the correct x- and y-coordinate.
The collider did not create any collision shapes as they failed verification. This could be because they were deemed too small or the vertices were too close. Vertices can also become close under certain rotations or very small scaling. This is the message that appears in the inspector when the enemy sprite expires. By the way, the z coordinate of the enemy doesn’t change. It is always the same even after the sprite is gone.
Does the collider change its size when the enemy disappears?
Perhaps you could share a screenshot of the enemy’s Inspector before and after the sprite disappared. Collapse the Animator because I’m mainly interested in the Transform and the BoxCollider2D component.
As I suspected, the scale values are 0. See here:
Check your code. Maybe the y- and z-values get set to 0 there. Only the x-value may get “flipped”/changed. y and z must be set to 1f.
Great Nina! I had to change a Vector2 in a Vector3!!! Thanks Nina, really appreaciate it. Excellent work. Now it works perfectly. Brava ;D
Awesome!
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.