0 votes

Hey guys,
Any idea how can I change progressively angular velocity on RigidBody2D . I am trying to rotate circle. I used on my rigidbody get_node("WheelComponentsRigid").set_angular_velocity(4)
and i tried with Node Timer to do something but it is not smart . :S
Any idea I am stacked up :S

Thank you in advance !

in Engine by (22 points)

2 Answers

0 votes
Best answer

you can also add use a tween.

Add a tween to your main node, then add this in the script:

onready var tween = get_node("tween")

func changevelocity():
tween.removeall()
tween.interpolate
property(getnode("WheelComponentsRigid"), "velocity/angular", 0, 4, 1.0, Tween.TRANSLINEAR, Tween.EASE_OUT, 0)
tween.start()

by (281 points)
selected by

I can't get transtype and easytype that's in your code Tween.TRANSLINEAR, Tween.EASE_OUT and I am not sure about property "velocity/angular". @ludosar

Underscore characters have been stripped out, here is the formatted code:

onready var tween = get_node("tween")

func change_velocity():
    tween.remove_all()
    tween.interpolate_property(get_node("WheelComponentsRigid"), "velocity/angular", 0, 4, 1.0, Tween.TRANS_LINEAR, Tween.EASE_OUT, 0)
    tween.start()
+1 vote

Do you want this to be an animated value, or a "motor" acceleration when the player presses "accelerate"?

For the first case, I would try to animate the angular_velocity property (if there is one?) with an AnimationPlayer.

For the latter, I would do something like this in _process:

if must_accelerate:
    if wheel.get_angular_velocity() < max_velocity:
        wheel.set_angular_velocity(wheel.get_angular_velocity() + acceleration*delta)

max_velocity being an angle/second and acceleration being in spaceUnit/secondsĀ² (spaceUnit being meters or whatever you choose)

by (28,735 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.