extends Spatial

var camera_distance = 2

func _ready():
	set_process(true)

	$Spatial/Spatial/Camera.translation = camera_distance * Vector3(0, 5, 5)
	$Spatial/Spatial/Camera.rotation_degrees = Vector3(-35, 0, 0)
	
func _process(delta):
	# Left & Right Rotation
	if Input.is_key_pressed(KEY_Q):
		$Spatial.rotate_y(5 * delta)
	elif Input.is_key_pressed(KEY_E):
		$Spatial.rotate_y(-5 * delta)

	# Up & Down Rotation
	if Input.is_key_pressed(KEY_W):
		$Spatial/Spatial.rotate_x(5 * delta)
	elif Input.is_key_pressed(KEY_S):
		$Spatial/Spatial.rotate_x(-5 * delta)

	# Zoomin & Zoomout
	if Input.is_key_pressed(KEY_EQUAL):
		$Spatial.set_scale($Spatial.get_scale() - Vector3(0.8, 0.8, 0.8) * delta)
	elif Input.is_key_pressed(KEY_MINUS):
		$Spatial.set_scale($Spatial.get_scale() + Vector3(0.8, 0.8, 0.8) * delta)

 

<참고>
http://www.bitoutsidethebox.com/godot-tutorial-5-2-axis-gimbal-camera-for-3d-games/

+ Recent posts