#how do we prevent really fast moving objects from clipping through walls
16 messages · Page 1 of 1 (latest)
PhysicsBody2D has the method move_and_collide() which uses continuous collision detection as far as i know. But of course that doesn't work with Area2D and the collision goes both ways.
You could only enable collision for the rocket while calling move_and_collide(), or alternatively make the hurtbox of targets a seperate StaticBody2d so the collisions won't impede the movement. One thing to note with the second approach is that Area2d is unable to detect StaticBody2d unless both monitoring and monitorable are set to true.
If that's an issue then using CharacterBody2D for the hurtbox would probably be better.
i thought of using a raycast and checking if there is a body between current position and position in previous frame 💀
might work too, but that would only be a line. it would be more performant, but the question is if it's good enough
wdym it would only be a line
if it passes through something i would just get the position of that thing and explode the rocket there
ig it wouldnt work if the rocket passed through multiple things
anyway if i use move_and_collide() i shouldnt need an area 2d anyway right
since move_and_collide() tells u if theres been a collision
the question if it's good enough would only consider edge cases like these:
so if your only problem is that it faces through solid walls if they're thin enough the raycast should be enough.
ahh
then i think ill go with the raycast
i mean most people wont even notice if that happens
even then your approach is probably better, since in Godot 4 they added the ShapeCast2D. So "upgrading" the collision shouldn't be too difficult