Add a first-view controller and a bunch of things
1. Replace 4k models with low-poly once 2. Use bare mixamo for testing 3. Add a basic menu 4. Add a map with collisions and spawn areas
This commit is contained in:
73
Demo/DemoWorld.tscn
Normal file
73
Demo/DemoWorld.tscn
Normal file
@ -0,0 +1,73 @@
|
||||
[gd_scene load_steps=10 format=3 uid="uid://0576fim4xnjw"]
|
||||
|
||||
[ext_resource type="Script" path="res://Demo/MainCamera.gd" id="1"]
|
||||
[ext_resource type="Script" path="res://addons/Mirror/Mirror/Mirror.gd" id="2"]
|
||||
|
||||
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_omm3q"]
|
||||
|
||||
[sub_resource type="Sky" id="Sky_bigpx"]
|
||||
sky_material = SubResource("ProceduralSkyMaterial_omm3q")
|
||||
|
||||
[sub_resource type="Environment" id="Environment_y6thg"]
|
||||
background_mode = 2
|
||||
sky = SubResource("Sky_bigpx")
|
||||
|
||||
[sub_resource type="SphereMesh" id="4"]
|
||||
radius = 1.0
|
||||
height = 2.0
|
||||
|
||||
[sub_resource type="CapsuleMesh" id="7"]
|
||||
radius = 0.33
|
||||
height = 1.66
|
||||
|
||||
[sub_resource type="FastNoiseLite" id="8"]
|
||||
|
||||
[sub_resource type="NoiseTexture2D" id="9"]
|
||||
seamless = true
|
||||
noise = SubResource("8")
|
||||
|
||||
[node name="DemoWorld" type="Node3D"]
|
||||
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||
environment = SubResource("Environment_y6thg")
|
||||
|
||||
[node name="MeshInstance2" type="MeshInstance3D" parent="."]
|
||||
transform = Transform3D(0.4, 0, 0, 0, 0.4, 0, 0, 0, 0.4, 0.311584, -0.508855, 0.519106)
|
||||
layers = 2
|
||||
mesh = SubResource("4")
|
||||
|
||||
[node name="MeshInstance3" type="MeshInstance3D" parent="."]
|
||||
transform = Transform3D(0.4, 0, 0, 0, 0.4, 0, 0, 0, 0.4, 0.4, 0.4, 0.773196)
|
||||
mesh = SubResource("4")
|
||||
|
||||
[node name="MeshInstance4" type="MeshInstance3D" parent="."]
|
||||
transform = Transform3D(0.3, 0, 0, 0, 0.3, 0, 0, 0, 0.3, 0.396369, 0.461957, -1.66788)
|
||||
mesh = SubResource("4")
|
||||
|
||||
[node name="Player" type="Node3D" parent="."]
|
||||
transform = Transform3D(0.733279, 0, -0.679928, 0, 1, 0, 0.679928, 0, 0.733279, -3.01042, 0.611678, 3.23258)
|
||||
script = ExtResource("1")
|
||||
|
||||
[node name="CameraRod" type="Node3D" parent="Player"]
|
||||
|
||||
[node name="MainCamera" type="Camera3D" parent="Player/CameraRod"]
|
||||
near = 0.3
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="Player/CameraRod"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.4, 0)
|
||||
mesh = SubResource("7")
|
||||
skeleton = NodePath("../../..")
|
||||
|
||||
[node name="Mirror" type="Node3D" parent="."]
|
||||
script = ExtResource("2")
|
||||
ResolutionPerUnit = 200
|
||||
MainCamPath = NodePath("../Player/CameraRod/MainCamera")
|
||||
MirrorColor = Color(1, 1, 1, 1)
|
||||
|
||||
[node name="Mirror2" type="Node3D" parent="."]
|
||||
transform = Transform3D(0.658492, 0, -0.752587, 0, 1, 0, 0.752587, 0, 0.658492, 2.4934, 0, 0.705538)
|
||||
script = ExtResource("2")
|
||||
ResolutionPerUnit = 200
|
||||
MainCamPath = NodePath("../Player/CameraRod/MainCamera")
|
||||
MirrorDistortion = 20
|
||||
DistortionTexture = SubResource("9")
|
108
Demo/MainCamera.gd
Normal file
108
Demo/MainCamera.gd
Normal file
@ -0,0 +1,108 @@
|
||||
extends Node3D
|
||||
|
||||
class_name TpsCamera
|
||||
|
||||
|
||||
# Nodes
|
||||
@onready var camera_pivot : Node3D = self
|
||||
@onready var camera_rod : Node3D = get_node("CameraRod")
|
||||
@onready var camera : Camera3D = get_node("CameraRod/MainCamera")
|
||||
|
||||
# Movement
|
||||
@export var mouse_sensitivity : float = 0.15
|
||||
@export var camera_min_vertical_rotation : float = -85.0
|
||||
@export var camera_max_vertical_rotation : float = 85.0
|
||||
|
||||
# zooming
|
||||
@export var camera_zoom : float = 3.0 : set = set_camera_zoom
|
||||
func set_camera_zoom(value): camera_zoom = clamp(value, camera_min_zoom_distance, camera_max_zoom_distance)
|
||||
@export var camera_min_zoom_distance : float = 3.0
|
||||
@export var camera_max_zoom_distance : float = 15.0
|
||||
@export var camera_zoom_step : float = 0.5
|
||||
|
||||
# Cursor
|
||||
@onready var is_cursor_visible : get = get_is_cursor_visible, set = set_is_cursor_visible
|
||||
func set_is_cursor_visible(value): Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE if value else Input.MOUSE_MODE_CAPTURED)
|
||||
func get_is_cursor_visible(): return Input.get_mouse_mode() == Input.MOUSE_MODE_VISIBLE
|
||||
|
||||
var speed = 0.1
|
||||
|
||||
|
||||
#####################
|
||||
# Default methods #
|
||||
#####################
|
||||
|
||||
func _ready() -> void:
|
||||
self.is_cursor_visible = false
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
process_basic_input()
|
||||
|
||||
if Input.is_action_pressed("ui_up"):
|
||||
self.global_transform.origin += - $CameraRod/MainCamera.global_transform.basis.z * speed
|
||||
if Input.is_action_pressed("ui_down"):
|
||||
self.global_transform.origin += $CameraRod/MainCamera.global_transform.basis.z * speed
|
||||
if Input.is_action_pressed("ui_right"):
|
||||
self.global_transform.origin += $CameraRod/MainCamera.global_transform.basis.x * speed
|
||||
if Input.is_action_pressed("ui_left"):
|
||||
self.global_transform.origin += - $CameraRod/MainCamera.global_transform.basis.x * speed
|
||||
#self.transform.origin = lerp(self.transform.origin, player.transform.origin, 0.1)
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
process_mouse_input(event)
|
||||
|
||||
|
||||
|
||||
####################
|
||||
# Camera3D methods #
|
||||
####################
|
||||
|
||||
|
||||
func rotate_camera(camera_direction : Vector2) -> void:
|
||||
self.rotation.y += -camera_direction.x
|
||||
# Vertical rotation
|
||||
camera_rod.rotate_x(-camera_direction.y)
|
||||
|
||||
# Limit vertical rotation
|
||||
camera_rod.rotation_degrees.x = clamp(
|
||||
camera_rod.rotation_degrees.x,
|
||||
camera_min_vertical_rotation, camera_max_vertical_rotation
|
||||
)
|
||||
|
||||
|
||||
|
||||
func toggle_cursor_visibility() -> void:
|
||||
self.is_cursor_visible = !self.is_cursor_visible
|
||||
|
||||
|
||||
|
||||
###################
|
||||
# Input methods #
|
||||
###################
|
||||
|
||||
func process_basic_input():
|
||||
if Input.is_action_just_pressed("ui_cancel"):
|
||||
toggle_cursor_visibility()
|
||||
|
||||
|
||||
func process_mouse_input(event : InputEvent) -> void:
|
||||
# Cursor movement
|
||||
if event is InputEventMouseMotion:
|
||||
var camera_direction = Vector2(
|
||||
deg_to_rad(event.relative.x * mouse_sensitivity),
|
||||
deg_to_rad(event.relative.y * mouse_sensitivity)
|
||||
)
|
||||
if !self.is_cursor_visible:
|
||||
rotate_camera(camera_direction)
|
||||
|
||||
# Scrolling
|
||||
elif event is InputEventMouseButton:
|
||||
if event.is_pressed() and not self.is_cursor_visible:
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
self.camera_zoom -= camera_zoom_step
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
self.camera_zoom += camera_zoom_step
|
||||
|
||||
|
7
Demo/default_env.tres
Normal file
7
Demo/default_env.tres
Normal file
@ -0,0 +1,7 @@
|
||||
[gd_resource type="Environment" load_steps=2 format=2]
|
||||
|
||||
[sub_resource type="Sky" id=1]
|
||||
|
||||
[resource]
|
||||
background_mode = 2
|
||||
background_sky = SubResource( 1 )
|
Reference in New Issue
Block a user