0 votes

So, I have an object, it rotates by impulse and I need to know when it done full circle. Is there any easy way to do it?

in Engine by (30 points)

1 Answer

0 votes
Best answer

I wouldn't say this would be the best way, but one idea is just to accumulate the angular differences and check them. There is certainly a more direct way of calculating it if you extract all the variables, but my physics knowledge is rudimentary.

extends RigidBody2D

func _ready():
    prev_degrees = get_rotd()
    set_fixed_process(true)

var rotated_degrees = 0.0
var prev_degrees

func _fixed_process(delta):

    var curr_degrees = get_rotd()

    rotated_degrees += abs(abs(prev_degrees) - abs(curr_degrees))


    if(rotated_degrees >= 360.0):
        print("360 rotation")
        rotated_degrees -= 360.0

    prev_degrees = curr_degrees
by (5,200 points)
selected by

I've done something very similar to your idea, but they both looks like ugly bicycle ); Although, it works, so, thanks for suggestion!

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.