diff options
| author | Anson Bridges <bridges.anson@gmail.com> | 2022-09-04 14:57:56 -0700 |
|---|---|---|
| committer | Anson Bridges <bridges.anson@gmail.com> | 2022-09-04 14:57:56 -0700 |
| commit | a0967ebe815cd229b69fb9578f2288b95b2ddb28 (patch) | |
| tree | ce1b06b1d8226c64e3550d674df96a2308f18130 /scripts/cameras | |
| parent | 5dbe6302e437c5c1d4431b853c410aa1d52f9b3d (diff) | |
networked machine project. added broken airplane from previous project
Diffstat (limited to 'scripts/cameras')
| -rw-r--r-- | scripts/cameras/plane_armcam.gd | 26 | ||||
| -rw-r--r-- | scripts/cameras/player_firstperson.gd | 33 |
2 files changed, 59 insertions, 0 deletions
diff --git a/scripts/cameras/plane_armcam.gd b/scripts/cameras/plane_armcam.gd new file mode 100644 index 0000000..edb0284 --- /dev/null +++ b/scripts/cameras/plane_armcam.gd @@ -0,0 +1,26 @@ +extends SpringArm + + + +# Called when the node enters the scene tree for the first time. +func _ready(): + Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) + $ClippedCamera.add_exception(get_parent()) + add_excluded_object(get_parent().get_rid()) + + +#func _process(delta): + + +func _input(event): + if $ClippedCamera.current: + if Input.is_action_just_pressed("menu"): #toggle mouse capture on esc + if Input.get_mouse_mode() == Input.MOUSE_MODE_VISIBLE: + Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) + else: + Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) + + if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED: + if event is InputEventMouseMotion: + rotation_degrees.x = clamp(rotation_degrees.x-event.relative.y*0.1,-70,70) + rotation_degrees.y -= event.relative.x*0.1 diff --git a/scripts/cameras/player_firstperson.gd b/scripts/cameras/player_firstperson.gd new file mode 100644 index 0000000..ace49e6 --- /dev/null +++ b/scripts/cameras/player_firstperson.gd @@ -0,0 +1,33 @@ +extends Camera + + +var mouse_axis := Vector2() +var mouse_sensitivity = 12.0 + +func _ready(): + Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) + current = false + + +func _input(event): + if current: + if Input.is_action_just_pressed("menu"): #toggle mouse capture on esc + if Input.get_mouse_mode() == Input.MOUSE_MODE_VISIBLE: + Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) + else: + Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) + if event is InputEventMouseMotion and Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED: + mouse_axis = event.relative + if mouse_axis.length() > 0: + var horizontal: float = -mouse_axis.x * (mouse_sensitivity / 100) + var vertical: float = -mouse_axis.y * (mouse_sensitivity / 100) + + mouse_axis = Vector2() + + get_parent().rotate_y(deg2rad(horizontal)) + rotate_x(deg2rad(vertical)) + + var temp_rot: Vector3 = rotation_degrees + temp_rot.x = clamp(temp_rot.x, -90, 90) + get_parent().animationcontroller.rpc("lean",-1*temp_rot.x/90) + rotation_degrees = temp_rot |
