#how do we prevent really fast moving objects from clipping through walls

16 messages · Page 1 of 1 (latest)

burnt sierra
#

I made a rocket whose velocity increases really fast since i add it with a multiple of itself. so it goes really fast causing it to clip through some thinner walls

kindred meadow
#

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.

burnt sierra
kindred meadow
#

might work too, but that would only be a line. it would be more performant, but the question is if it's good enough

burnt sierra
#

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

kindred meadow
#

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.

burnt sierra
#

then i think ill go with the raycast

#

i mean most people wont even notice if that happens

kindred meadow
#

even then your approach is probably better, since in Godot 4 they added the ShapeCast2D. So "upgrading" the collision shouldn't be too difficult