Skip to content

Instantly share code, notes, and snippets.

@erdavids
Created December 18, 2021 22:29
Show Gist options
  • Save erdavids/0820293c257c19e307dc63e5c076fb08 to your computer and use it in GitHub Desktop.
Save erdavids/0820293c257c19e307dc63e5c076fb08 to your computer and use it in GitHub Desktop.
extends RigidBody
var rotating = false
var prev_mouse_position
var next_mouse_position
func _process(delta):
if (Input.is_action_just_pressed("Rotate")):
rotating = true
prev_mouse_position = get_viewport().get_mouse_position()
if (Input.is_action_just_released("Rotate")):
rotating = false
if (rotating):
next_mouse_position = get_viewport().get_mouse_position()
rotate_y((next_mouse_position.x - prev_mouse_position.x) * .1 * delta)
rotate_z(-(next_mouse_position.y - prev_mouse_position.y) * .1 * delta)
prev_mouse_position = next_mouse_position
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment