I used Rigidbody2d to control my Player but the Rotation Point isnt on the Player

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Schnom

As said, i used Rigidbody2d to control my Player, i then grabbed some Code from a Tutorial and modified it a little, but for some reason, when i press the Input to rotate the Player around, it seems to rotate around a Point a good bit infront of the Player. What do i need to change to fix this?

Heres the Code:

extends RigidBody2D

export (int) var engine_thrust
export (int) var spin_thrust

var thrust = Vector2()
var rotation_dir = 0
var screensize

func _ready():
screensize = get_viewport().get_visible_rect().size

func get_input():
if Input.is_action_pressed("ui_up"):
	thrust = Vector2(engine_thrust, 0)
else:
	thrust = Vector2()
rotation_dir = 0
if Input.is_action_pressed("ui_right"):
	rotation_dir += 1
if Input.is_action_pressed("ui_left"):
	rotation_dir -= 1

func _process(delta):
get_input()

func _physics_process(delta):
set_applied_force(thrust.rotated(rotation))
set_applied_torque(rotation_dir * spin_thrust)

Isn’t it an issue with your Sprite2D ? Check if its position is aligned with position of body in editor. Try if your code works with Godot icon as a Sprite.

Inces | 2022-01-11 17:08