0 votes

It is necessary that Area2D accept the value "rotation_Degrees" and move in its direction

in Engine by (101 points)

1 Answer

+1 vote
Best answer

I offer two options:

1) Set the rotation and then rotate your movement vector by that amount:

func _ready():
    rotation_degrees = 45

func _process(delta):
    position += Vector2.(1, 0).rotated(rotation) * speed * delta

2) Use the body's transform to move forward on its local axis:

func _ready():
    rotation_degrees = 45

func _process(delta):
    position += transform.x * speed * delta

There are several examples here that you can use if you need more detail: https://docs.godotengine.org/en/latest/tutorials/2d/2d_movement.html

by (20,483 points)
selected by
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 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 webmaster@godotengine.org with your username.