Skip to main content
deleted 69 characters in body
Source Link

@skrx Not only does this work, this actually shortens the code!

This allows removing the fmod adjustments, and the if statement used to change the rotational direction past its half-way point, only rotating the shortest distance:, and removes the use of Center entirely!

if abs(angle) > PI :
    angle = -angle

I did have to change the &gt and &lt symbols back to your original orientation (I had to switch them for my rotation difference method to work)

The new code is as follows, and works exactly as intended, thanks again!

func _process(delta):
    center.look_at(get_global_mouse_position())
    
    var angular_speed = 2
    var angle = get_local_mouse_position().angle()
    if abs(angle) > .05:
        if angle < 0:
            rotate(-angular_speed*delta)
        elif angle > 0:
            rotate(angular_speed*delta)

@skrx Not only does this work, this actually shortens the code!

This allows removing the fmod adjustments, and the if statement used to change the rotational direction past its half-way point, only rotating the shortest distance:

if abs(angle) > PI :
    angle = -angle

I did have to change the &gt and &lt symbols back to your original orientation (I had to switch them for my rotation difference method to work)

The new code is as follows, and works exactly as intended, thanks again!

func _process(delta):
    center.look_at(get_global_mouse_position())
    
    var angular_speed = 2
    var angle = get_local_mouse_position().angle()
    if abs(angle) > .05:
        if angle < 0:
            rotate(-angular_speed*delta)
        elif angle > 0:
            rotate(angular_speed*delta)

@skrx Not only does this work, this actually shortens the code!

This allows removing the fmod adjustments, and the if statement used to change the rotational direction past its half-way point, only rotating the shortest distance, and removes the use of Center entirely!

I did have to change the &gt and &lt symbols back to your original orientation (I had to switch them for my rotation difference method to work)

The new code is as follows, and works exactly as intended, thanks again!

func _process(delta):
    var angular_speed = 2
    var angle = get_local_mouse_position().angle()
    if abs(angle) > .05:
        if angle < 0:
            rotate(-angular_speed*delta)
        elif angle > 0:
            rotate(angular_speed*delta)
Source Link

@skrx Not only does this work, this actually shortens the code!

This allows removing the fmod adjustments, and the if statement used to change the rotational direction past its half-way point, only rotating the shortest distance:

if abs(angle) > PI :
    angle = -angle

I did have to change the &gt and &lt symbols back to your original orientation (I had to switch them for my rotation difference method to work)

The new code is as follows, and works exactly as intended, thanks again!

func _process(delta):
    center.look_at(get_global_mouse_position())
    
    var angular_speed = 2
    var angle = get_local_mouse_position().angle()
    if abs(angle) > .05:
        if angle < 0:
            rotate(-angular_speed*delta)
        elif angle > 0:
            rotate(angular_speed*delta)