Hi, I have problem with my script:
func _input(event):
if event.is_action_released("ui_accept"): # when I am pressing a key
get_node("RigidBody2D").set_rotd(get_rotd()-5) # RigidBody2D is rotating to check collision
if !is_colliding(): # if collision is false
get_node("Tween").interpolate_property(self, "transform/rot", 0, -90, 1, Tween.TRANS_QUAD, Tween.EASE_IN_OUT) # animation is...
get_node("Tween").start() # ... starting
After making this action my object should stay still (without any rotation, because is_colliding()
return true
but after pressing a key object is rotating very slightly (it's not perfect 0 degrees).
For a test I have made function like this:
func _input(event):
if event.is_action_pressed("ui_accept"): # when I am pressing a key
get_node("RigidBody2D").set_rotd(get_rotd()-5) # RigidBody2D is rotating to check collision
for x in range(0, 1): # and starts short loop
if x == 0: # at 0...
if is_colliding() == true:# ... it's checking for collision
break # and eventually break
else: # or continue
continue
if x == 1: at 1...
get_node("Tween").interpolate_property(self, "transform/rot", get_rotd(), get_rotd()-90, 1, Tween.TRANS_QUAD, Tween.EASE_IN_OUT) # animation is...
get_node("Tween").start() # ... starting
And this one is working ok but it's looks like a mess. How should I deal with this problem correctly?
Best :)