landgreen / n-gon

2-d physics rogue-lite platformer shooter
https://landgreen.github.io/n-gon/
GNU General Public License v3.0
151 stars 222 forks source link

Bug: Bullets travelling through walls (not wave or that nail upgrade) #190

Closed The-Rock-21 closed 6 months ago

The-Rock-21 commented 6 months ago

Kinda explanatory. Bullets like shotgun and nail gun (with or without no upgrades) can travel through walls. Just stand right next to a wall with those guns and shoot in the wall. It only works on walls that aren't too thick

landgreen commented 6 months ago

This is a known limitation of physics engines. My approach in n-gon is make walls thick, but also don't worry about it because in the real world bullets go through thin walls.

AnnonymousNerd87 commented 6 months ago

Yes, this issue is well documented, although I thought you could fix it with ray tracing/casting The issue is that small fast objects can 'phase' through walls if they never collide with it due to fps limitations, because computers only compute physics once per frame/tick and if an object is on one side of a wall in one frame/tick and the other in the next frame/tick, the computer won't know the wall was ever in the way. Ray tracing/casting draws a metaphorical invisible line between the pre-image and image to determine if a wall is in the way, if it is then it will move the object directly in front of the wall and recalculate the physics so all the normal collision happens. Ray tracing/casting can be very effective for preventing this, but it takes a significant toll on fps so I wouldn't recommend it on projectiles or blocks, but for m and mobs/bosses it might be helpful idk I don't use it much so what do I have to say