Commit 21c5d336 authored by yannk's avatar yannk

Merge branch 'master' of...

Merge branch 'master' of ssh://git.khaganat.net:3543/khaganat/mmorpg_khanat/khanat-assets---3d-godot-client
parents f836e824 13da264b
......@@ -5,4 +5,3 @@
[resource]
background_mode = 2
background_sky = SubResource( 1 )
extends Spatial
var _mouse_look = false
var _mouse_position = Vector2( 0.0, 0.0 )
var _yaw = 0.0
var _pitch = 0.0
var _total_yaw = 0.0
var _total_pitch = 0.0
var _current_camera_speed = 1.0
export(int) var yaw_limit = 360
export(int) var pitch_limit = 360
export(float) var camera_sensitivity = 0.5
export(float) var camera_smoothness = 0.5
export(float) var camera_speed = 1.0
export(float) var camera_accel = 10.0
func _ready():
self._current_camera_speed = self.camera_speed
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_up"):
$dummy/camera_stand.translate( Vector3( 0.0, self._current_camera_speed*delta, 0.0 ) )
elif Input.is_action_pressed("move_down"):
$dummy/camera_stand.translate( Vector3( 0.0,-self._current_camera_speed*delta, 0.0 ) )
elif Input.is_action_pressed("move_forward"):
$dummy/camera_stand.translate( Vector3( 0.0, 0.0,-self._current_camera_speed*delta ) )
elif Input.is_action_pressed("move_backward"):
$dummy/camera_stand.translate( Vector3( 0.0, 0.0, self._current_camera_speed*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 ) )
$dummy/camera_stand.translate( Vector3(-self._current_camera_speed*delta, 0.0, 0.0 ) )
elif Input.is_action_pressed("move_right"):
$dummy/camera_stand.translate( Vector3( self._current_camera_speed*delta, 0.0, 0.0 ) )
if _mouse_look:
_update_mouselook()
func _update_mouselook():
_mouse_position *= self.camera_sensitivity
_yaw = _yaw * self.camera_smoothness + _mouse_position.x * (1.0 - self.camera_smoothness)
_pitch = _pitch * self.camera_smoothness + _mouse_position.y * (1.0 - self.camera_smoothness)
_mouse_position = Vector2(0, 0)
if yaw_limit < 360:
_yaw = clamp(_yaw, -yaw_limit - _total_yaw, yaw_limit - _total_yaw)
if pitch_limit < 360:
_pitch = clamp(_pitch, -pitch_limit - _total_pitch, pitch_limit - _total_pitch)
_total_yaw += _yaw
_total_pitch += _pitch
$dummy/camera_stand.rotate_y(deg2rad(-_yaw))
$dummy/camera_stand.rotate_object_local(Vector3(1,0,0), deg2rad(-_pitch))
func _input(event):
if event.is_action_pressed( "move_look" ):
Input.set_mouse_mode( Input.MOUSE_MODE_CAPTURED )
self._mouse_look = true
elif event.is_action_released( "move_look" ):
Input.set_mouse_mode( Input.MOUSE_MODE_VISIBLE )
self._mouse_look = false
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 )
if _mouse_look:
_mouse_position = event.relative
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 )
\ No newline at end of file
if event.is_action_pressed( "move_speed" ):
self._current_camera_speed = self.camera_speed + self.camera_accel
elif event.is_action_released( "move_speed" ):
self._current_camera_speed = self.camera_speed
\ No newline at end of file
......@@ -71,4 +71,3 @@ shadow_enabled = true
[node name="gi_probe" type="GIProbe" parent="light_system"]
extents = Vector3( 63.192, 10, 76.3229 )
data = SubResource( 5 )
......@@ -56,6 +56,21 @@ move_zoom_out={
"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":5,"pressed":false,"doubleclick":false,"script":null)
]
}
move_up={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":true,"meta":false,"command":true,"pressed":false,"scancode":16777232,"unicode":0,"echo":false,"script":null)
]
}
move_down={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":true,"meta":false,"command":true,"pressed":false,"scancode":16777234,"unicode":0,"echo":false,"script":null)
]
}
move_speed={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777237,"unicode":0,"echo":false,"script":null)
]
}
[node]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment