I have a playercontroller 2d in top-down view game, where the players ship follows the cursor. When I increase cursor speed it rotates with it instantly. And I want players to feel some weight, so make the ship rotating with some delay. How can I do it? Would be grateful for help. Controller code below. (Player.gd)
extends KinematicBody2D
export var move_speed = 250
export var stop_distance = 20
var playercoord = Vector2()
func _process(delta):
_look_at_mouse()
_move_to_mouse()
if G.player_alive == 1:
playercoord = get_node("/root/MainScene/Player").get_position()
func _look_at_mouse():
look_at(get_global_mouse_position())
rotation_degrees = rotation_degrees + 90
func _move_to_mouse():
if position.distance_to(get_global_mouse_position()) > stop_distance:
var direction = get_global_mouse_position() - position
move_and_slide(direction)
ALSO, I've got enemies, and I want them to have weight slightly bigger than player, to have him feel he's a bit faster and subtle than the enemies. It's part of enemies controller code:
it's in the phys-process:
if player:
if G.player_alive == 1:
var direction = (player.position - position).normalized()
move_and_slide(direction * MOVE_SPEED)
pass
func _look_at_player():
look_at(playercoord)
rotation_degrees = rotation_degrees + 90