The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

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)
    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):

func _physics_process(delta):
set_applied_torque(rotation_dir * spin_thrust)
Godot version v3.4.2
in Engine by (20 points)

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.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.