Compare commits

..

2 Commits

Author SHA1 Message Date
6d50a76cff Add universal HUD 2025-02-12 14:07:28 +01:00
1d8d47a248 Add more notes, fix 5 room level
in the 5 room level you were able to see a portal through a portal, which glitched out a little
2025-02-12 13:41:53 +01:00
8 changed files with 82 additions and 42 deletions

View File

@ -2,6 +2,12 @@
- 11.2.2024
## Optat se
- Udělám pár technických vylepšení a jinak se zaměřím na DX portálů - gizma, guidy, procedural mesh
- Téma DP do IS?
- Kdy se odevzdává DP?
## Poznámky k implementaci
### 5 roomka
@ -12,6 +18,11 @@ venkovního úhlu. Protože reálně jsem od něj mega daleko, takže portálov
### Island level
- Dolní collider jsem musel hodně zvětšit aby skrz něj hráč neproletěl během 1 physics framu
- Horní jsem musel trochu potočit, jinak se hráč objevil zrcadlově??
- Zapnout/Vypnout tadyto *proporční* teleportování? V MC se člověk objeví asi uprostřed nether
portálu i když je kde chce
- Kdybych chtěl mesh do dveří (oblouk), možná by bylo jednodušší udělat masku než spešl mesh.
Viewport je čtveratý tak jako tak.
### Semafor
@ -20,3 +31,4 @@ venkovního úhlu. Protože reálně jsem od něj mega daleko, takže portálov
- Zkusil jsem vymodelovat vlastní mesh v blenderu. Moc to nefunguje, Godot je asi zmatený z toho
že on má Y-up a Blender používá Z-up. V portal repu je k tomu poznámka ale nepochopil jsem to asi.
- Divně se na ten mesh pak projektuje ta textura kamery??
- Možná by stálo za to udělat procedurální mesh. Nejběžnější tvar portálu bude asi obdélník

25
hud.gd Normal file
View File

@ -0,0 +1,25 @@
extends VBoxContainer
func _ready() -> void:
toggle_hud() # This should hide the HUD by default
func _process(delta: float) -> void:
if Input.is_action_just_pressed("ui_cancel"):
toggle_hud()
func toggle_hud() -> void:
var should_show = Input.mouse_mode == Input.MOUSE_MODE_CAPTURED
if should_show:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
show()
else:
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
hide()
func _on_menu_button_pressed() -> void:
var err = get_tree().change_scene_to_file("res://menu.tscn")
if err != OK:
print("Failed to switch scenes: ", error_string(err))

1
hud.gd.uid Normal file
View File

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

13
hud.tscn Normal file
View File

@ -0,0 +1,13 @@
[gd_scene load_steps=2 format=3 uid="uid://b5x7fmpwck335"]
[ext_resource type="Script" uid="uid://dys441ih752an" path="res://hud.gd" id="1_37p78"]
[node name="HUD" type="VBoxContainer"]
script = ExtResource("1_37p78")
[node name="MenuButton" type="Button" parent="."]
unique_name_in_owner = true
layout_mode = 2
text = "Back to Menu"
[connection signal="pressed" from="MenuButton" to="." method="_on_menu_button_pressed"]

View File

@ -1,10 +1,11 @@
[gd_scene load_steps=10 format=3 uid="uid://27pb62xwsqd8"]
[gd_scene load_steps=11 format=3 uid="uid://27pb62xwsqd8"]
[ext_resource type="MeshLibrary" uid="uid://bedqgubx1g1uf" path="res://prototypes.tres" id="1_mqqdr"]
[ext_resource type="Script" uid="uid://d2bvvjsibau8c" path="res://addons/simple-portal-system/scripts/portal.gd" id="2_b14t7"]
[ext_resource type="ArrayMesh" uid="uid://bqilnvlfws6xh" path="res://portal-mesh.tres" id="2_cgnft"]
[ext_resource type="PackedScene" uid="uid://cgdlowfuuorvi" path="res://player.tscn" id="3_b0o0q"]
[ext_resource type="Script" uid="uid://bkv7t4hw21byg" path="res://addons/simple-portal-system/scripts/simple_portal_teleport.gd" id="4_snwvi"]
[ext_resource type="PackedScene" uid="uid://b5x7fmpwck335" path="res://hud.tscn" id="6_phjvl"]
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_b0o0q"]
sky_horizon_color = Color(0.662243, 0.671743, 0.686743, 1)
@ -23,6 +24,10 @@ size = Vector3(2, 2, 0.5)
[node name="level_3rooms" type="Node3D"]
[node name="HUD" parent="." instance=ExtResource("6_phjvl")]
offset_right = 137.0
offset_bottom = 23.0
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_snwvi")

File diff suppressed because one or more lines are too long

View File

@ -8,6 +8,7 @@
[ext_resource type="Script" uid="uid://d2bvvjsibau8c" path="res://addons/simple-portal-system/scripts/portal.gd" id="5_wg85y"]
[ext_resource type="Script" uid="uid://bkv7t4hw21byg" path="res://addons/simple-portal-system/scripts/simple_portal_teleport.gd" id="6_3fidx"]
[ext_resource type="ArrayMesh" uid="uid://bqilnvlfws6xh" path="res://portal-mesh.tres" id="7_hwdx8"]
[ext_resource type="PackedScene" uid="uid://b5x7fmpwck335" path="res://hud.tscn" id="9_2wcgd"]
[sub_resource type="Environment" id="Environment_7knre"]
background_mode = 1
@ -20,9 +21,6 @@ size = Vector3(2, 1, 2)
[sub_resource type="BoxShape3D" id="BoxShape3D_2wcgd"]
size = Vector3(2, 2.5, 8.79824)
[sub_resource type="ViewportTexture" id="ViewportTexture_hwdx8"]
viewport_path = NodePath("SubViewport")
[node name="Main" type="Node3D"]
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
@ -302,17 +300,4 @@ fade_out_color = Color(0.590126, 0.615058, 0.699408, 1)
exit_cull_mask = 1048573
exit_portal = NodePath("../P_bottom")
[node name="SubViewport" type="SubViewport" parent="."]
size = Vector2i(512, 288)
[node name="Camera3D" type="Camera3D" parent="SubViewport"]
transform = Transform3D(-0.00436047, 0.491726, -0.870739, 0, 0.870747, 0.491731, 0.999991, 0.00214418, -0.00379687, -34.9621, 17.276, -0.665714)
fov = 52.5
[node name="CanvasLayer" type="CanvasLayer" parent="."]
[node name="TextureRect" type="TextureRect" parent="CanvasLayer"]
visible = false
offset_right = 512.0
offset_bottom = 288.0
texture = SubResource("ViewportTexture_hwdx8")
[node name="HUD" parent="." instance=ExtResource("9_2wcgd")]

View File

@ -7,15 +7,9 @@ const JUMP_VELOCITY = 4.5
const MOUSE_SENSITIVITY = 0.005
func _ready() -> void:
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
func _process(delta: float) -> void:
if Input.is_action_just_pressed("ui_cancel"):
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
func _unhandled_input(event: InputEvent) -> void:
if event is InputEventMouseMotion:
if Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
rotate_y(-event.screen_relative.x * MOUSE_SENSITIVITY)
camera.rotate_x(-event.screen_relative.y * MOUSE_SENSITIVITY)
camera.rotation.x = clamp(camera.rotation.x, deg_to_rad(-80), deg_to_rad(80))