gd: fixed look inputs

This commit is contained in:
2025-05-29 09:49:56 +02:00
parent 5104144ba3
commit c3e2c974ca
21 changed files with 348 additions and 558 deletions

View File

@ -0,0 +1,30 @@
using Godot;
using System;
public partial class HeadSystem : Node3D
{
private Camera3D _camera;
[Export(PropertyHint.Range, "0,10,0.1,or_greater")]
public float LookSensitivity { get; set; } = 1f;
public void Init()
{
Input.SetMouseMode(Input.MouseModeEnum.Captured);
_camera = GetNode<Camera3D>("CameraSmooth/Camera3D");
}
public void LookAround(Vector2 lookDir)
{
// Horizontal movement of head
float angleForHorizontalRotation = lookDir.X * LookSensitivity;
RotateY(angleForHorizontalRotation);
// Vertical movement of head
Vector3 currentCameraRotation = _camera.Rotation;
currentCameraRotation.X += Convert.ToSingle(lookDir.Y * LookSensitivity);
currentCameraRotation.X = Mathf.Clamp(currentCameraRotation.X, Mathf.DegToRad(-90f), Mathf.DegToRad(90f));
_camera.Rotation = currentCameraRotation;
}
}

View File

@ -0,0 +1 @@
uid://dtkdrnsmlwm67

View File

@ -0,0 +1,59 @@
[gd_scene load_steps=6 format=3 uid="uid://0ysqmqphq6mq"]
[ext_resource type="Script" uid="uid://dtkdrnsmlwm67" path="res://systems/head/HeadSystem.cs" id="1_8abgy"]
[ext_resource type="Material" uid="uid://dtq8i1ka1f2pn" path="res://player_controller/Assets/Materials/Health/CameraVignette.tres" id="2_urko7"]
[ext_resource type="Material" uid="uid://nyh5tn1yoxeu" path="res://player_controller/Assets/Materials/Health/CameraDistortion.tres" id="3_0hyrq"]
[ext_resource type="Shader" uid="uid://btw6vsb6sa7sn" path="res://player_controller/Shaders/Blur.gdshader" id="4_ubhf8"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_o1np4"]
shader = ExtResource("4_ubhf8")
shader_parameter/limit = 0.0
shader_parameter/blur = 0.0
[node name="HeadSystem" type="Node3D"]
script = ExtResource("1_8abgy")
[node name="CameraSmooth" type="Node3D" parent="."]
[node name="Camera3D" type="Camera3D" parent="CameraSmooth"]
transform = Transform3D(0.15, 0, 0, 0, 0.15, 0, 0, 0, 0.15, 0, 0, 0)
current = true
[node name="CLVignette(Layer_1)" type="CanvasLayer" parent="CameraSmooth/Camera3D"]
[node name="HealthVignetteRect" type="ColorRect" parent="CameraSmooth/Camera3D/CLVignette(Layer_1)"]
material = ExtResource("2_urko7")
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
[node name="CLDistortion(Layer_2)" type="CanvasLayer" parent="CameraSmooth/Camera3D"]
layer = 2
[node name="HealthDistortionRect" type="ColorRect" parent="CameraSmooth/Camera3D/CLDistortion(Layer_2)"]
material = ExtResource("3_0hyrq")
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
[node name="CLBlur(Layer_2)" type="CanvasLayer" parent="CameraSmooth/Camera3D"]
layer = 2
[node name="BlurRect" type="ColorRect" parent="CameraSmooth/Camera3D/CLBlur(Layer_2)"]
material = SubResource("ShaderMaterial_o1np4")
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
[node name="RayCast3D" type="RayCast3D" parent="CameraSmooth/Camera3D"]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, -0.64723)
visible = false