0 votes

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 moveandcollide, 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

in Engine by (170 points)

1 Answer

0 votes
Best answer

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

by (1,193 points)
selected by

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...

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

What if you want to keep on using moveand...? 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?

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.