Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Ga1lus |
So what I am doing is rotation an area2d then rotation a vector2 based on the rotation of the area2d, then i rotate the vector back acording to the rotation of the area2d * -1. But the final result has has changed from what it was firts. So I dont know if thats just something on how the math works or what.
How can I fix this so that the final vector2 is the same as the first one after it has been rotated and rotated back again by the same amount?
Hopefully the video can explain it better than I can
the code-
extends Area2D
var vector1 = Vector2(0, -100)
var vector2 = Vector2(0, 0)
var turn = 0.0
Called when the node enters the scene tree for the first time.
func _ready():
print("ready")
func _process(delta):
if Input.is_action_pressed("right"):
turn = clamp(turn + 1, -1, 1)
if Input.is_action_pressed("left"):
turn = clamp(turn + -1, -1, 1)
rotation += turn
turn = 0.0
vector2 = vector1.rotated(get_rotation())
#print(vector2)
print(vector2.rotated(get_rotation() * -1))