sometimes the bullets colide but most of the time they just go right through each other.
the bullet is a rigid body2d and is only a sprite and a collision shape
the enemy is a kinematic2d with a sprite, collision shape, area2d, and the area 2d has another collision shape.
the code for the bullet is,
if Input.is_action_just_pressed("LMB"):
fire()
func fire():
var bullet_instance = bullet.instance()
bullet_instance.position = get_global_position()
bullet_instance.rotation_degrees = rotation_degrees
bullet_instance.apply_impulse(Vector2(), Vector2(bullet_speed,0).rotated(rotation))
get_tree().get_root().call_deferred("add_child",bullet_instance)
and it is inside the player node,
the code for the enemy is,
extends KinematicBody2D
var motion = Vector2()
func _physics_process(_delta):
var player = get_parent(). get_node("Player")
position += (player.position - position)/50
look_at(player.position)
move_and_collide(motion)
so does anyone know a fix for this?