Passing thru a kinematic body

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By lowpolygon

Is it possible to make a kinematicbody 2D to pass thru another one while getting the collision information ?
For example, if i am to make something like a armor piercing bullet, if I use move_and_collide, it would stop when it hits another kinematicbody.
One way I can think off is instead of using kinematicbody for bullet, I use area2D. But I am not sure if there is anything I should concern about moving an area 2D object Since tutorial and docs pretty much say if I want to move with physic I should use kinematic body

:bust_in_silhouette: Reply From: rustyStriker

Moving an area2D will simply mean you don’t have the option to stop on a wall and bounce or slide on it, since movement is video games is basically teleporting an object so slightly between frames it gives it the feel of continues movement(thus you require about 60 fps usually). Using the kinematicBody and PhysicsBody nodes means you can use the built in functions of move_and_... and set_linear_velocity respectively, those function will calculate the path it will go in a certain frame and ask if there is any collisions occurring during the frame, and making the calculations required to simulate collisions…

if you are planning to free the bullet as soon as it hits a wall and not have any collision what so ever that will indeed bounce the bullet or make it slide somewhere you can safely use are2D as the bullet’s physics object and use

position += Velocity_vector * delta

as the movement for the bullet

Thanks, I guess area2D it is then . Other than piercing ammo , pretty much all ammo will destroy on impact. And with piercing ammo, it will destroy itself after certain time…

lowpolygon | 2019-12-13 10:11

Well, if ALL bullets destroy themselves upon impact then you probably better off without a kinematicBody, a fun little(sort of) bug you get when using a bullet with only a kinematicBody is when the bullet is moving away from the player and the player walks after the bullet faster than the bullet, sometimes it just thinks the bullet is a wall or something, so the player detects the bullet but the bullet doesnt detect the player, fun stuff

rustyStriker | 2019-12-13 10:16

What if you want to keep on using move_and_…? For example I don’t want my projectiles to teleport through the object they are supposed to hit. Is there a better work around than switching to area2D?

Hapiel | 2021-06-01 11:26

you can use move_and_collide on a kinematic body, but simply having a KinematicBody means the Physics server will try its hardest to make stuff not overlap and penetrate

rustyStriker | 2021-06-01 13:39