0 votes

I created a slider and now I want the slider can control the angle of a 2D polygon.

In reviews people say Godot is beginner friendly but it doesn't seem so because the most simple things like trigger an event with a slider change doesn't work.

And all I do in visual script doesn't work and there aren't any information to find how to get a change impulse which can trigger something.

in Engine by (12 points)

1 Answer

0 votes

I have no idea of how to do it in VisualScript (and honestly wouldn't recommend anyone to work with VisualScript anyhow), but in GDScript it's very easy.

Let's say your scene-tree looks like this:

- Main (Node-Type: Node2D)
    - Polygon (Node-Type: Polygon2D)
    - Slider (Node-Type: HSlider)

Then you would connect the Slider's value_changed-signal to a callback named _on_Slider_value_changed, let's say that's a function in the Main-script:

extends Node2D    

func _on_HSlider_value_changed(value):
    get_node("Polygon").global_rotation = value
by (10,063 points)

I still don't get it. Nothing works. Can you create a quick project file to demonstrate how a hslider change refresh the angle of an object?

Sorry for the late reply, had some busy weeks! If you're still struggling with this, take a look at the example project I uploaded here: https://easyupload.io/7ackww (That link will stop working after 30 days) If you haven't yet, I'd recommend you work through this part of the documentation - it will teach you a lot of fundamentals.

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.

Categories