mirror of
https://gitlab.com/open-fpsz/open-fpsz.git
synced 2026-04-24 22:05:34 +00:00
96 lines
3.3 KiB
Text
96 lines
3.3 KiB
Text
[gd_scene load_steps=9 format=3 uid="uid://cbhx1xme0sb7k"]
|
|
|
|
[ext_resource type="Script" path="res://characters/player/player.gd" id="1_ymjub"]
|
|
[ext_resource type="PackedScene" uid="uid://bcv81ku26xo" path="res://interfaces/hud/hud.tscn" id="2_5qvi2"]
|
|
[ext_resource type="PackedScene" uid="uid://c8co0qa2omjmh" path="res://weapons/space_gun/space_gun.tscn" id="2_ka38u"]
|
|
|
|
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_clur0"]
|
|
bounce = 1.0
|
|
absorbent = true
|
|
|
|
[sub_resource type="CapsuleMesh" id="CapsuleMesh_vmqfq"]
|
|
|
|
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_rm4oh"]
|
|
|
|
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_3l0v2"]
|
|
|
|
[sub_resource type="GDScript" id="GDScript_qcxi0"]
|
|
script/source = "extends SpringArm3D
|
|
|
|
@export var MOUSE_SENSITIVITY : float = 0.5
|
|
@export var WHEEL_SENSITIVITY : float = 0.5
|
|
|
|
var _mouse_position: Vector2
|
|
var _mouse_rotation : Vector3
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready():
|
|
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
|
$Camera3D.current = true
|
|
|
|
|
|
func _unhandled_input(event: InputEvent) -> void:
|
|
var mouse_mode = Input.get_mouse_mode()
|
|
|
|
# isolate mouse events
|
|
if event is InputEventMouseMotion:
|
|
if mouse_mode == Input.MOUSE_MODE_CAPTURED:
|
|
# retrieve mouse position relative to last frame
|
|
_mouse_position = event.relative * MOUSE_SENSITIVITY
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
func _process(delta):
|
|
_update_camera(delta)
|
|
|
|
func _update_camera(delta):
|
|
# clamp vertical rotation (head motion)
|
|
_mouse_rotation.y -= _mouse_position.y * delta
|
|
_mouse_rotation.y = clamp(_mouse_rotation.y, deg_to_rad(-90.0),deg_to_rad(90.0))
|
|
# wrap horizontal rotation (to prevent accumulation)
|
|
_mouse_rotation.x -= _mouse_position.x * delta
|
|
_mouse_rotation.x = wrapf(_mouse_rotation.x, deg_to_rad(0.0),deg_to_rad(360.0))
|
|
# reset mouse motion until next input event
|
|
_mouse_position = Vector2.ZERO
|
|
# update spring arm global rotation
|
|
global_transform.basis = Basis.from_euler(Vector3(_mouse_rotation.y, _mouse_rotation.x, 0.0))
|
|
"
|
|
|
|
[node name="Player" type="RigidBody3D"]
|
|
axis_lock_angular_x = true
|
|
axis_lock_angular_y = true
|
|
axis_lock_angular_z = true
|
|
mass = 75.0
|
|
physics_material_override = SubResource("PhysicsMaterial_clur0")
|
|
continuous_cd = true
|
|
script = ExtResource("1_ymjub")
|
|
|
|
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
|
visible = false
|
|
mesh = SubResource("CapsuleMesh_vmqfq")
|
|
|
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
|
shape = SubResource("CapsuleShape3D_rm4oh")
|
|
|
|
[node name="ShapeCast3D" type="ShapeCast3D" parent="."]
|
|
transform = Transform3D(1.05, 0, 0, 0, 1.05, 0, 0, 0, 1.05, 0, 0, 0)
|
|
shape = SubResource("CapsuleShape3D_3l0v2")
|
|
target_position = Vector3(0, 0, 0)
|
|
collide_with_areas = true
|
|
|
|
[node name="HUD" parent="." instance=ExtResource("2_5qvi2")]
|
|
|
|
[node name="SpringArm3D" type="SpringArm3D" parent="."]
|
|
unique_name_in_owner = true
|
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
|
|
spring_length = 0.0
|
|
script = SubResource("GDScript_qcxi0")
|
|
|
|
[node name="Camera3D" type="Camera3D" parent="SpringArm3D"]
|
|
fov = 100.0
|
|
near = 0.1
|
|
|
|
[node name="Inventory" type="Node3D" parent="SpringArm3D"]
|
|
|
|
[node name="SpaceGun" parent="SpringArm3D/Inventory" instance=ExtResource("2_ka38u")]
|
|
transform = Transform3D(-1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, 0.145, -0.095, -0.261784)
|