Here is the only thing you need to shoot your RigidBody at the mouse:
# projectile.gd
extends RigidBody2D
export var speed = 100.0
func shoot_at_mouse(start_pos):
self.global_position = start_pos
var direction = (get_global_mouse_position() - start_pos).normalized()
self.linear_velocity = direction * speed
And for example, you would shoot it like this:
# shooter.gd
extends Sprite
func _input(event):
if event is InputEventMouseButton:
if event.pressed:
var projectile = preload("res://projectile.tscn").instance()
get_parent().add_child(projectile)
projectile.shoot_at_mouse(self.global_position)
Also if you want to get rid of gravity you can set gravity scale
to zero in your RigidBody.