khanat-assets---3d-godot-cl.../previewer/previewer.gd

30 lines
1.3 KiB
GDScript3
Raw Normal View History

extends Spatial
func _process( delta ):
if Input.is_action_pressed("move_forward"):
$dummy/camera_stand.translate( Vector3( 0.0, 0.0,-10.0*delta ) )
if Input.is_action_pressed("move_backward"):
$dummy/camera_stand.translate( Vector3( 0.0, 0.0, 10.0*delta ) )
if Input.is_action_pressed("move_left"):
$dummy/camera_stand.translate( Vector3(-10.0*delta, 0.0, 0.0 ) )
if Input.is_action_pressed("move_right"):
$dummy/camera_stand.translate( Vector3( 10.0*delta, 0.0, 0.0 ) )
func _input(event):
if event.is_action_pressed( "move_look" ):
Input.set_mouse_mode( Input.MOUSE_MODE_CAPTURED )
elif event.is_action_released( "move_look" ):
Input.set_mouse_mode( Input.MOUSE_MODE_VISIBLE )
if event is InputEventMouseMotion:
if Input.is_action_pressed( "move_look" ):
$dummy/camera_stand/camera.rotate_x( -event.relative.y * 0.01 )
$dummy/camera_stand.rotate_y( -event.relative.x * 0.01 )
2019-04-25 20:48:24 +00:00
if event.is_action_pressed( "move_zoom_in" ):
$dummy/camera_stand/camera.set_fov( $dummy/camera_stand/camera.get_fov()-1.0 )
elif event.is_action_pressed( "move_zoom_out" ):
$dummy/camera_stand/camera.set_fov( $dummy/camera_stand/camera.get_fov()+1.0 )