Camera Updates

This commit is contained in:
ncusimano 2023-08-19 11:30:53 -06:00
parent aa25e5c772
commit 61cd28172c
3 changed files with 16 additions and 16 deletions

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=3 format=3 uid="uid://bgoo1lbt28na"] [gd_scene load_steps=3 format=3 uid="uid://bmx4xpa5svia3"]
[ext_resource type="PackedScene" uid="uid://bhanbx2dyhv2d" path="res://Models/grape_man.glb" id="1_fh5yr"] [ext_resource type="PackedScene" uid="uid://bhanbx2dyhv2d" path="res://Models/grape_man.glb" id="1_fh5yr"]
[ext_resource type="Script" path="res://Models/grape_man.gd" id="2_ksje8"] [ext_resource type="Script" path="res://Models/grape_man.gd" id="2_ksje8"]

View File

@ -6,6 +6,7 @@ const JUMP_VELOCITY = 4.5
@export var horiz_sens = 0.25 @export var horiz_sens = 0.25
@export var vert_sens = 0.25 @export var vert_sens = 0.25
var playerCam var playerCam
var playerVisuals
# Get the gravity from the project settings to be synced with RigidBody nodes. # Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity = ProjectSettings.get_setting("physics/3d/default_gravity") var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
@ -13,6 +14,7 @@ var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
func _ready(): func _ready():
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
playerCam = get_node("CameraMount") as Node3D playerCam = get_node("CameraMount") as Node3D
playerVisuals = get_node("grape_man") as Node3D
func _process(delta): func _process(delta):
@ -25,7 +27,8 @@ func _input(event):
# Handle the rotation of the camera using mouse movement. # Handle the rotation of the camera using mouse movement.
if event is InputEventMouseMotion: if event is InputEventMouseMotion:
rotate_y(deg_to_rad(-event.relative.x * horiz_sens)) rotate_y(deg_to_rad(-event.relative.x * horiz_sens))
playerCam.rotate_x(deg_to_rad(-event.relative.y * vert_sens)) playerVisuals.rotate_y(deg_to_rad(event.relative.x * horiz_sens))
playerCam.rotate_x(deg_to_rad(event.relative.y * vert_sens))
func _physics_process(delta): func _physics_process(delta):
# Add the gravity. # Add the gravity.

View File

@ -1,28 +1,25 @@
[gd_scene load_steps=6 format=3 uid="uid://csqyxbjumla33"] [gd_scene load_steps=4 format=3 uid="uid://csqyxbjumla33"]
[ext_resource type="Script" path="res://Player.gd" id="1_7gpdp"] [ext_resource type="Script" path="res://Player.gd" id="1_7gpdp"]
[ext_resource type="Texture2D" uid="uid://vw0x1higed4d" path="res://Default Orange.png" id="2_s5i4o"] [ext_resource type="PackedScene" uid="uid://bmx4xpa5svia3" path="res://Models/grape_man.tscn" id="2_hha22"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_kb4ms"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_1yhh3"]
radius = 1.2
[sub_resource type="CapsuleMesh" id="CapsuleMesh_1e11l"] height = 5.8
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_npbs0"]
albedo_texture = ExtResource("2_s5i4o")
[node name="Player" type="CharacterBody3D"] [node name="Player" type="CharacterBody3D"]
script = ExtResource("1_7gpdp") script = ExtResource("1_7gpdp")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."] [node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("CapsuleShape3D_kb4ms") transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3, 0)
shape = SubResource("CapsuleShape3D_1yhh3")
[node name="MeshInstance3D" type="MeshInstance3D" parent="."] [node name="grape_man" parent="." instance=ExtResource("2_hha22")]
mesh = SubResource("CapsuleMesh_1e11l") transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, 0)
surface_material_override/0 = SubResource("StandardMaterial3D_npbs0")
[node name="CameraMount" type="Node3D" parent="."] [node name="CameraMount" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.3, 0) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.45879, 0)
[node name="PlayerCam" type="Camera3D" parent="CameraMount"] [node name="PlayerCam" type="Camera3D" parent="CameraMount"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 4) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 7)
fov = 105.5 fov = 105.5