Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | roxasthewise | |
Old Version | Published before Godot 3 was released. |
Hi, i have certain problem about drawing a line from Vector2(0,0) to direction of my object.
It seems that if i rotate my object 90 degrees, the line rotates 180 degrees, it’s like the line always rotate twice degrees of my object.
I hope that you guys can help me.
here’s my code
func _fixed_process(delta):
update()
process_input()
process_movement(delta)
func _draw():
draw_line(direction * 100, Vector2(0,0), Color(1,1,1))
func process_input():
if(Input.is_key_pressed(KEY_A)):
orientation += rotationSpeed
if(orientation > maxAngle):
orientation -= 360
if(Input.is_key_pressed(KEY_D)):
orientation -= rotationSpeed
if(orientation < 0):
orientation = 0 - (orientation - 360)
set_rotd(orientation)
func process_movement(delta):
direction.x = sin(get_rot())
direction.y = cos(get_rot())