Godot Version
v4.3.stable.official [77dcf97d8]
Question
I am running into a problem with firing bullets. I have a player that is a rigidbody2d and a gun that fires another rigidbody2d. If the initial linear_velocity of the projectile is high, then it is fine. But if it is too low and the player is moving fast the player overtakes the projectile. When I generate the projectile I set its linear_velocity based on the direction aimed * projectile speed. Then I add the player’s linear_velocity to it. But I still overtake the projectile. Is there a better way of including in the parent velocity in the projectiles velocity?
func shoot( direction, inherited_inertia):
_life = 0
var target_velocity = direction * projectile_speed
if(inherits_inertia):
target_velocity += inherited_inertia
$RigidBody2D.linear_velocity = target_velocity
$RigidBody2D.contact_monitor = true
_in_flight = true
Should I apply the parent’s velocity as a force? Or an impulse? Or something else to kick the projectile faster?