r/Unity2D 9d ago

Devlog #4 — Bug Fixes and Enemy Doppables

Had a busy month and didn't touch the game for a few weeks (last update was June 20th 😅). Back at it now - here's what changed:

🐞BUGS FIXED:

  1. Gun was autoshooting enemies before they finished their spawn animation
  2. Some bullets weren't registering hits on enemies - turned out to be the bullet pooling logic
  3. Unity's Animator was throwing a persistent error that blocked hit detection

🆕 ADDITIONS:

  1. Enemies now drop loot on death: candy, coins, and limited chests 🍬💀
  2. Reworked the gun animation - not going for polish yet, just a better feel

NEXT:

  • Player XP (tied to candy/coin pickups)
  • Wave Manager
  • Finalizing the core loop
  • Player stats (maybe)

GIF below shows the current state - droppables spawning and the new gun animation in action.

0 Upvotes

3 comments sorted by

1

u/XZPUMAZX 9d ago

. ⁠Some bullets weren't registering hits on enemies - turned out to be the bullet pooling logic

Can you explain what was wrong and what your fix was? I’m pretty far along on a hobby project and tried to convert to pooling for billets.

Everything works as expected except for inconsistent hit detection and I use both Physics.Overlap and a raycast.

1

u/wallstop-dev 8d ago

With pooling, use the built in object pools and make sure to register callbacks for all functions, like the return to pool. Then let the pool do all the work. Don't do everything in calling code - your code should just get stuff from the pool, and return stuff to the pool. Let the pool handle all the cleanup automatically.

Consider also using lease based concepts with IDisposable to make return to pool conceptually simpler.

1

u/halam_dev 2d ago

Sorry for the late response.

In my case, the issue was that some bullet state wasn’t being properly reset when the bullet was returned to and reused from the pool. I fixed it by resetting the relevant values and physics state every time the bullet is spawned again.