According to what I understood, you can use applycentralimpulse () or apply_impulse. Something like that:
extends RigidBody2D
var temp=true
func _ready():
pass
func _physics_process(delta):
var pos=self.position
var mpos=get_global_mouse_position()
if pos.distance_to(mpos) < 50 and temp:
self.linear_damp=5
self.apply_central_impulse((pos-mpos).normalized() * 350)
temp=false
if pos.distance_to(mpos) > 50:
temp=true
EDIT:
I forgot that for rigidbody another process function is used, it would be something like that but I don't know if it's the behavior you expect:
extends RigidBody2D
var max_force=150
var max_speed=150
var temp=true
# seek() is called here
func _integrate_forces(state):
linear_damp=2
apply_central_impulse(seek().clamped(max_force))
# Function to seek player
func seek():
var player_loc = get_global_mouse_position() # Test variable to get mouse's position
var steer=Vector2(0,0)
# Get the desired velocity towards the player
var desired = (player_loc - get_global_position()).normalized()
desired *= (max_speed)
if self.position.distance_to(player_loc) < 100 and temp:
steer = desired - get_linear_velocity()
temp= false
if self.position.distance_to(player_loc) > 100:
temp=true
return steer