Godot Version
4.3
Question
Setting:
2D top-down Space game. Gravity is turned off. Player’s ship is Characterbody2D, controlled by standard move_and_slide().
Player’s rotation is defined by simple code:
var cursor_pos := get_global_mouse_position()
var angle_to_cur = position.angle_to_point(cursor_pos)
rotation = rotate_toward(rotation, angle_to_cur, PI*delta)
Objects are standard Rigidbody2Ds with collisionshape. For example, and asteroid. They have very high mass and generally cannot be pushed far by Player.
Problem:
If I start rotating the player near objects, causing collision by this rotation, this creates extreme forces on the Rigidbody2Ds, flinging them away as if they have no mass. The problem is especially bad if i rotate the player in tight spaces (like lodged between 2 Rigidbody2Ds or if Rigidbody2D has a crevice that is big enough for the player’s collision shape to get into.
What I need help with:
I somehow either need to make sure that:
Option 1(Preferable):
On any contact caused by rotation the pushed body is always the player’s Characterbody2D (or at least there is a strict limit to the force applied to RigidBody2Ds).
and/or
Option 2 (less preferable):
Prohibit rotation of the player if it causes contact with other objects.
Can anyone give e a hint, how this can be done? Thank you!