Restore camera controller
This commit is contained in:
@@ -1,19 +1,15 @@
|
||||
[gd_scene load_steps=11 format=3 uid="uid://2ch34sio36nv"]
|
||||
[gd_scene load_steps=10 format=3 uid="uid://2ch34sio36nv"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://ylmy3nvpirgr" path="res://entities/player/Player.gd" id="1_24gqh"]
|
||||
[ext_resource type="Script" uid="uid://bwxdv3kxrs4oj" path="res://entities/player/PlayerMovement.gd" id="2_o7et6"]
|
||||
[ext_resource type="Script" uid="uid://b3nty7pvbo58d" path="res://entities/player/PlayerInteraction.gd" id="3_24gqh"]
|
||||
[ext_resource type="Script" uid="uid://bdv1fj1pwknrs" path="res://entities/player/PlayerInput.gd" id="4_yjynp"]
|
||||
[ext_resource type="Script" uid="uid://bdjgvyiacbg28" path="res://entities/player/PlayerCamera.gd" id="5_g3lhm"]
|
||||
[ext_resource type="Material" uid="uid://bx0778wr1ge00" path="res://materials/EntityMaterial.tres" id="6_4pwj0"]
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_2m2ha"]
|
||||
|
||||
[sub_resource type="CapsuleMesh" id="CapsuleMesh_g13of"]
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_g13of"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_g13of"]
|
||||
albedo_color = Color(0.0156863, 0.282353, 1, 1)
|
||||
[sub_resource type="QuadMesh" id="QuadMesh_fmb3c"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_g13of"]
|
||||
size = Vector3(0.705444, 0.680542, 1.17688)
|
||||
@@ -37,20 +33,18 @@ script = ExtResource("4_yjynp")
|
||||
interaction = NodePath("../PlayerInteraction")
|
||||
movement = NodePath("../PlayerMovement")
|
||||
|
||||
[node name="PlayerCamera" type="Node" parent="Scripts" node_paths=PackedStringArray("camera")]
|
||||
[node name="PlayerCamera" type="Node" parent="Scripts" node_paths=PackedStringArray("camera", "target")]
|
||||
script = ExtResource("5_g3lhm")
|
||||
camera = NodePath("../../PlayerCamera")
|
||||
target = NodePath("../..")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
shape = SubResource("CapsuleShape3D_2m2ha")
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||
mesh = SubResource("CapsuleMesh_g13of")
|
||||
|
||||
[node name="MeshInstance3D2" type="MeshInstance3D" parent="."]
|
||||
transform = Transform3D(0.598863, 0, 0, 0, 0.598863, 0, 0, 0, 0.598863, 0, 0.441532, 0.539694)
|
||||
mesh = SubResource("BoxMesh_g13of")
|
||||
surface_material_override/0 = SubResource("StandardMaterial3D_g13of")
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="CollisionShape3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0)
|
||||
mesh = SubResource("QuadMesh_fmb3c")
|
||||
surface_material_override/0 = ExtResource("6_4pwj0")
|
||||
|
||||
[node name="PlayerInteractableArea" type="Area3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.185831, 0.817421)
|
||||
|
@@ -1,6 +1,28 @@
|
||||
class_name PlayerCamera extends Node
|
||||
|
||||
const CAMERA_PIXELS_PER_UNIT = 32.0
|
||||
const CAMERA_PIXEL_SCALE = 1.0
|
||||
|
||||
@export var camera:Camera3D = null
|
||||
@export var target:Node3D = null
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
# I tried a few things but this is most consistent for both backbuffer and
|
||||
# framebuffer viewports.
|
||||
var viewportHeight = get_viewport().get_visible_rect().size.y;
|
||||
var unitScale = CAMERA_PIXEL_SCALE * CAMERA_PIXELS_PER_UNIT;
|
||||
|
||||
var z:float = (
|
||||
tan((deg_to_rad(180) - deg_to_rad(camera.fov)) / 2.0) *
|
||||
(viewportHeight / 2.0)
|
||||
) / unitScale;
|
||||
|
||||
var look = target.global_position;
|
||||
var position = Vector3(0, 0, 2) + look;
|
||||
|
||||
camera.look_at_from_position(
|
||||
Vector3(position.x, position.y + z, position.z),
|
||||
look
|
||||
);
|
||||
|
||||
pass
|
||||
|
@@ -1,12 +1,21 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://cluuhtfjeodwb"]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://cluuhtfjeodwb"]
|
||||
|
||||
[ext_resource type="Material" uid="uid://chuogedj81c5" path="res://materials/WorldMaterial.tres" id="1_x4ibw"]
|
||||
|
||||
[sub_resource type="PlaneMesh" id="PlaneMesh_owt5q"]
|
||||
size = Vector2(10, 10)
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_x4ibw"]
|
||||
size = Vector3(10, 0.1, 10)
|
||||
|
||||
[node name="TestMapBase" type="Node3D"]
|
||||
|
||||
[node name="Ground" type="MeshInstance3D" parent="."]
|
||||
[node name="Ground" type="StaticBody3D" parent="."]
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="Ground"]
|
||||
mesh = SubResource("PlaneMesh_owt5q")
|
||||
skeleton = NodePath("../..")
|
||||
surface_material_override/0 = ExtResource("1_x4ibw")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Ground"]
|
||||
shape = SubResource("BoxShape3D_x4ibw")
|
||||
|
9
materials/EntityMaterial.tres
Normal file
9
materials/EntityMaterial.tres
Normal file
@@ -0,0 +1,9 @@
|
||||
[gd_resource type="ShaderMaterial" load_steps=3 format=3 uid="uid://bx0778wr1ge00"]
|
||||
|
||||
[ext_resource type="Shader" uid="uid://be6ueh411xro5" path="res://materials/WorldMaterialShader.gdshader" id="1_h67lk"]
|
||||
[ext_resource type="Texture2D" uid="uid://cu1hvpqmqn31n" path="res://icon.svg" id="2_7766c"]
|
||||
|
||||
[resource]
|
||||
render_priority = 0
|
||||
shader = ExtResource("1_h67lk")
|
||||
shader_parameter/text = ExtResource("2_7766c")
|
Reference in New Issue
Block a user