Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | ahmadred |
I am trying to rotate an arrow based on the speed of the node. I need the arrow to rotate slower the faster the arrow is going.
extends RigidBody2D
export var impulse = 1500
var velocity = Vector2(0,0)
func _ready():
apply_impulse(Vector2(0,0), Vector2(impulse,0))
pass
func _process(delta):
velocity = get_linear_velocity()
pass
func _physics_process(delta):
if rad2deg(rotation) < 90 && rad2deg(rotation) > -90:
set_angular_velocity(velocity.x/1000) #this is just reducing the value
else:
set_angular_velocity(0)
$debugBox.text = String(rad2deg(rotation))
pass
Basically when the speed is at 1000 I want to rotation to be at 0.01, and when the speed is at 1 i want to rotation speed to be around 10.