I am trying to get my character to rotate 90 degrees, I have tried many different numbers but my character only rotates a tiny bit unless I use numbers like 1000+. Am I misunderstanding something here?

if event.is_action_pressed("rotate_left"):
global_rotation_degrees = deg_to_rad(-290)
if event.is_action_pressed("rotate_right"):
global_rotation_degrees = deg_to_rad(290)

  • xyz replied to this.
  • xRegnarokx Try this:

    if Input.is_action_just_pressed("rotate_left"):
    	rotation_degrees -= 90
    if Input.is_action_just_pressed("rotate_right"):
    	rotation_degrees += 90

    xRegnarokx You assign to global_rotation_degrees yet for some reason convert your angles to radians. Radians are much smaller than degrees, that's why you get only small rotations. Use degrees value directly without converting it to radians. If you want to deal with radians then assign angle in radians to global_rotation

      xyz Hey thanks for that, I managed to mess around a bit and figured out how to do the 90 degree rotation, but I am currently stumped on how to rotate from current facing direction, rather than original.

      Example it will rotate right 90 degrees, then I can't rotate it any more unless I rotate it left, and it will jump 180 degrees, 90 degrees from start, and then I can only switch between these two locations.

      `func process(delta):
      var curr_pos = the_object.position
      if Input.is_action_just_pressed("accelerate"):
      the_object.global_position = curr_pos + Vector2(0,-105)
      if Input.is_action_just_pressed("decelerate"):
      the_object.global_position = curr_pos + Vector2(0,105)
      if Input.is_action_just_pressed("rotate_left"):
      rotation_degrees = deg_to_rad(-90)
      rotate(rotation_degrees)
      if Input.is_action_just_pressed("rotate_right"):
      rotation_degrees = (deg_to_rad(90))
      rotate(rotation_degrees)

      • xyz replied to this.

        xRegnarokx Try this:

        if Input.is_action_just_pressed("rotate_left"):
        	rotation_degrees -= 90
        if Input.is_action_just_pressed("rotate_right"):
        	rotation_degrees += 90