+1 vote

Hi all I have a ball that is launched sort of like a angry birds situation, so basically I manage to make it all the way where you can launch the ball 3 times, and I managed to make the Arrow appear, but I have no idea how to make it rotate, any pointers would be greatly appreciated :) I marked the line with <<------ this is the line that does nothing.

extends RigidBody2D

var dragging
var drag_start = Vector2()
var drag_end = Vector2()
var launched = false
var try= 3
const Arrow = preload('res://scenes/Player/Arrow.tscn')
var arrow = null
var dir

func _ready():
    arrow = Arrow.instance()

func _input(event):
    if (try != 0):
        if event.is_action_pressed("click") and not dragging and not launched:
            dragging = true
            arrow.get_rotation() <<-----------------NO ROTATION HERE, NADA
            drag_start = get_global_mouse_position()
        if event.is_action_released("click") and dragging:
            dragging = false
            launched = true
            try -= 1
            drag_end = get_global_mouse_position()
            dir = drag_start - drag_end
            apply_impulse(Vector2(), dir * 5)
            yield(get_tree().create_timer(5.0), "timeout")
            launched = false
in Engine by (29 points)

1 Answer

0 votes

arrow.get_rotation() does not cause rotation to happen, it exists to give you access to the current rotation state. You need to use arrow.set_rotation(radians) or arrow.rotation = radians if you want to change the node's rotation.

by (629 points)
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.