2D Physics Strange Behaviour

Godot Version



I’m making a 2D space shooter. The spaceship is a rigidbody 2D controller by the following code:

extends RigidBody2D

const ROTATION_SPEED = 5.0
const THRUST_FORCE = 10
const TORQUE = 1
const MAX_VELOCITY = 5
const INTERPOLATION_SPEED: float = 0.5

@export var bullet : PackedScene

var camera: Camera2D
var collisionPolygon: CollisionPolygon2D

var interpolated_mass: float
var t: float
var thrust: float
var _min_v: Vector2
var _max_v: Vector2

func _ready():
	camera = $Camera2D
	collisionPolygon = $CollisionPolygon2D
	interpolated_mass = mass
	t = 1.0
	thrust = 0.0
	_min_v = Vector2(-MAX_VELOCITY, -MAX_VELOCITY)
	_max_v = -_min_v

func _process(_delta):
	#Thrust input
	thrust = int(Input.is_action_pressed("thrust_forward")) * THRUST_FORCE
	# Shoot input

	# Mass interpolation
	if t < 1:
		t = 1.0
	interpolated_mass = lerp(interpolated_mass, mass, t)
	collisionPolygon.scale = Vector2(interpolated_mass, interpolated_mass)
	camera.zoom = (Vector2.ONE*6)/(interpolated_mass*1.5)

func _physics_process(_delta):
	# Looking at mouse
	rotation_degrees += 90
	#Limit velocity
	linear_velocity = linear_velocity.clamp(_min_v, _max_v)

func _integrate_forces(state):
	state.apply_force(Vector2(0, -thrust).rotated(rotation))

func change_mass(value):
	mass += value
	t = 0

func shoot():
	var b: Node2D = bullet.instantiate() as Node2D
	b.position = self.global_position
	b.rotation = self.global_rotation - PI/2
	b.get_node("./Shape").scale = scale

I don’t know why but when the ship hits an asteroid the physics behaviour feels off. The ship pushes asteroids only the moment it touches them but after that moment it stop pushing them further. What am I missing?

I don’t understand. Debugging the code _integrate_forces function is called continuosly. It seems collisons prevent the ship to move but its linear velocity remains unchanged