#2D Bullets without real physics but collision

1 messages · Page 1 of 1 (latest)

scarlet copper
#

Hello everyone, I need some quick hints. I am just starting to learn Godot, but I am a software engineer, so programming and such itself is no problem.

After finishing the 2D tutorial I am currently trying to create a very simple Brotato Clone.

For that I already have the player, enemies, bullets and stuff like that. But I have a problem with the collisions. The Enemies are CharacterBody2D with a CollisionShape2D child. Now I want to fire bullets which move in a straight line with constant speed and can hit the enemy.

In my tests I had bullets with a RigidBody2D and the enemies where just Area2D at that point. With that it worked fine. But now that my Enemies are CharacterBody2D (which I believe they should be, so they can't 'enter' each other), the bullets just collide with them and stay there. Previously my enemies had on_body_entered and there the bullets hit the.

What Node type should my bullets be and which would be teh best way to let them hit the Enemies (CharacterBody2D)?

#

2D Bullets without real physics but collision

opal kraken
#

oh you can class your bullet node with a script and then just queue free it, if i’m understanding the problem correctly. for actual collisions you just create a collision on the bullet like i think you already did

scarlet copper
#

Yes, I already use queue_free on the bullets.

But now that I use a CharaterBody2D for the enemies, together with RigidBody2D for the bullets, they don't intersect anymore. I tried to show it a bit in the image (was hard to capture a perfect image). Here the bullets collide with the enemy, loose al their force and just drop down.

Where could I check for the collision between the two? on_body_entered doesn't work anymore, they don't enter.

That's why I am also asking if RigidBody2D is even teh correct choice here?

wispy lintel
#

You can add area2d as a child of your rigid body with slightly larger collision shape than the bullet and then connect on body entered to your bullet script