Перейти к содержимому

I Fixed the Background. My Unity Enemy Broke Physics

Tajbuild

0:00 / 0:00

I Fixed the Background. My Unity Enemy Broke Physics

12 просмотров · 13 дней назад
Tajbuild
4 подписчика
12 просмотров · 13 дней назад
The background finally works properly. Naturally, the enemies have now decided to cause problems instead. In this episode of the Gemio Unity devlog, I started by fixing the scenic background’s unpredictable framing. The image was sometimes appearing at roughly twice its expected scale, causing a completely different portion of it to appear whenever I entered Play Mode. After stabilizing the background fitting, I added a subtle parallax effect so the distant scenery moves more slowly than the player and foreground. The effect initially stopped after roughly the first tenth of the level because the background quickly reached the edge of the available image. I lowered the parallax amount to 0.06, which gives the level some depth without revealing the image boundaries too quickly. Then enemy physics took over the episode. Running into a patrol enemy could launch it into the air instead of producing a clean contact-damage interaction. Updating the collision handling stopped the player from physically throwing the enemy around—but that exposed another problem. If the player remained pressed against the enemy, only the initial collision removed health. The player could then continue running into it indefinitely without taking more damage until the two objects separated and collided again. I updated the contact-damage logic so the enemy can damage the player again after the existing invulnerability period, even when the original collision is still being maintained. Finally, I noticed an unnatural visible gap between the player and enemy when contact damage occurred. Their CapsuleCollider2D shapes were touching at their curved edges before the sprites appeared to make contact. Replacing both capsule colliders with properly sized BoxCollider2D components made the collision look much more natural. By the end of the episode: • The scenic background fits consistently • Subtle parallax works at 0.06 • Enemies no longer get launched during contact • Sustained contact can damage the player again • Player and enemy sprites visually meet when colliding Source code: https://github.com/tajbuild/Gemio #Unity #GameDev #IndieGame #Unity2D #Devlog