Working Camera

Camera Works!
This commit is contained in:
ncusimano 2023-08-18 23:15:14 -06:00
parent 5b8fb7b298
commit 0d0f255827
4 changed files with 58 additions and 10 deletions

View File

@ -1,16 +1,20 @@
[gd_scene load_steps=3 format=3 uid="uid://dd64j7xcfl6io"] [gd_scene load_steps=4 format=3 uid="uid://dd64j7xcfl6io"]
[ext_resource type="PackedScene" uid="uid://csqyxbjumla33" path="res://player.tscn" id="1_i6frr"] [ext_resource type="PackedScene" uid="uid://csqyxbjumla33" path="res://player.tscn" id="1_i6frr"]
[ext_resource type="PackedScene" uid="uid://3d51hjh2st8a" path="res://Level/Island.tscn" id="2_cjk1r"]
[sub_resource type="BoxShape3D" id="BoxShape3D_r81py"] [sub_resource type="CylinderShape3D" id="CylinderShape3D_cxihl"]
size = Vector3(10, 1, 10) radius = 15.365
[node name="Node3D" type="Node3D"] [node name="Node3D" type="Node3D"]
[node name="Player" parent="." instance=ExtResource("1_i6frr")] [node name="Player" parent="." instance=ExtResource("1_i6frr")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 7.93827, 12.3667, -12.0351)
[node name="RigidBody3D" type="RigidBody3D" parent="."] [node name="Node3D" parent="." instance=ExtResource("2_cjk1r")]
transform = Transform3D(10, 0, 0, 0, 10, 0, 0, 0, 10, -0.279051, -4.39988, -1.78854)
[node name="CollisionShape3D" type="CollisionShape3D" parent="RigidBody3D"] [node name="StaticBody3D" type="StaticBody3D" parent="Node3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -5, 0)
shape = SubResource("BoxShape3D_r81py") [node name="CollisionShape3D" type="CollisionShape3D" parent="Node3D/StaticBody3D"]
shape = SubResource("CylinderShape3D_cxihl")

View File

@ -3,6 +3,8 @@ extends CharacterBody3D
const SPEED = 5.0 const SPEED = 5.0
const JUMP_VELOCITY = 4.5 const JUMP_VELOCITY = 4.5
@export var horiz_sens = 0.25
@export var vert_sens = 0.25
var playerCam var playerCam
# 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.
@ -12,11 +14,18 @@ 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
func _process(delta):
# Brings your mouse out of the window if you press escape. Add pause screen function here?
if Input.is_action_pressed("ui_cancel"):
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
func _input(event): 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:
playerCam.rotate_y(deg_to_rad(-event.relative.x)) rotate_y(deg_to_rad(-event.relative.x * horiz_sens))
playerCam.rotate_x(deg_to_rad(event.relative.y)) 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

@ -24,5 +24,5 @@ surface_material_override/0 = SubResource("StandardMaterial3D_npbs0")
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, 0.3, 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, 2, 5) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 4)
fov = 105.5 fov = 105.5

View File

@ -22,3 +22,38 @@ project/assembly_name="abgj23"
[filesystem] [filesystem]
import/fbx/enabled=false import/fbx/enabled=false
[input]
ui_left={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194319,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":-1.0,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"echo":false,"script":null)
]
}
ui_right={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194321,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":14,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":1.0,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"echo":false,"script":null)
]
}
ui_up={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194320,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":11,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":-1.0,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"echo":false,"script":null)
]
}
ui_down={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194322,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":1.0,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"echo":false,"script":null)
]
}