Merge branch 'blockz' into stairs-map
This commit is contained in:
commit
4d549f708a
13
materials/building_block_hover.tres
Normal file
13
materials/building_block_hover.tres
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
[gd_resource type="ShaderMaterial" load_steps=2 format=3 uid="uid://pu02smf107o8"]
|
||||||
|
|
||||||
|
[ext_resource type="Shader" path="res://materials/building_block.gdshader" id="1_fkxdu"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
render_priority = 0
|
||||||
|
shader = ExtResource("1_fkxdu")
|
||||||
|
shader_parameter/albedo = Color(0.356373, 0.507339, 1, 1)
|
||||||
|
shader_parameter/roughness = 0.533
|
||||||
|
shader_parameter/specular = 0.45
|
||||||
|
shader_parameter/metallic = null
|
||||||
|
shader_parameter/uv1_scale = Vector3(1, 1, 1)
|
||||||
|
shader_parameter/uv1_offset = null
|
@ -121,6 +121,21 @@ toggle_pause_menu={
|
|||||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":6,"pressure":0.0,"pressed":true,"script":null)
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":6,"pressure":0.0,"pressed":true,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
interact={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(238, 22),"global_position":Vector2(252, 92),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
drag_orbit={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":4,"position":Vector2(272, 24),"global_position":Vector2(286, 94),"factor":1.0,"button_index":3,"canceled":false,"pressed":true,"double_click":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
release_block={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":2,"position":Vector2(224, 40),"global_position":Vector2(238, 110),"factor":1.0,"button_index":2,"canceled":false,"pressed":true,"double_click":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
toggle_noclip={
|
toggle_noclip={
|
||||||
"deadzone": 0.5,
|
"deadzone": 0.5,
|
||||||
"events": [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":4194334,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
"events": [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":4194334,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||||
|
@ -3,11 +3,12 @@
|
|||||||
[ext_resource type="CameraAttributesPhysical" uid="uid://cxyj2tvfksjl6" path="res://scenes/hazy_env_camera_attrs.tres" id="1_r2j1d"]
|
[ext_resource type="CameraAttributesPhysical" uid="uid://cxyj2tvfksjl6" path="res://scenes/hazy_env_camera_attrs.tres" id="1_r2j1d"]
|
||||||
[ext_resource type="PackedScene" uid="uid://br315evr8x2gt" path="res://scenes/hazy_env.tscn" id="2_le85m"]
|
[ext_resource type="PackedScene" uid="uid://br315evr8x2gt" path="res://scenes/hazy_env.tscn" id="2_le85m"]
|
||||||
[ext_resource type="LightmapGIData" uid="uid://bp05p4yab2ukx" path="res://scenes/demo/demo.lmbake" id="2_thfwf"]
|
[ext_resource type="LightmapGIData" uid="uid://bp05p4yab2ukx" path="res://scenes/demo/demo.lmbake" id="2_thfwf"]
|
||||||
[ext_resource type="PackedScene" uid="uid://d4fn0ljcmjdnb" path="res://scenes/demo/demo_map.tscn" id="4_0ojvw"]
|
[ext_resource type="PackedScene" uid="uid://bqts60gpnb82d" path="res://scenes/demo/demo_map.tscn" id="4_0ojvw"]
|
||||||
[ext_resource type="PackedScene" uid="uid://wjbuh7jk50nm" path="res://scenes/player.tscn" id="10_3xiy2"]
|
[ext_resource type="PackedScene" uid="uid://wjbuh7jk50nm" path="res://scenes/player.tscn" id="10_3xiy2"]
|
||||||
[ext_resource type="PackedScene" uid="uid://d02cqylu3xwos" path="res://scenes/table.tscn" id="11_7trvw"]
|
[ext_resource type="PackedScene" uid="uid://d02cqylu3xwos" path="res://scenes/table.tscn" id="11_7trvw"]
|
||||||
[ext_resource type="PackedScene" uid="uid://c670g1qg5gaug" path="res://scenes/interface/pause_menu.tscn" id="11_lav3p"]
|
[ext_resource type="PackedScene" uid="uid://c670g1qg5gaug" path="res://scenes/interface/pause_menu.tscn" id="11_lav3p"]
|
||||||
[ext_resource type="Material" uid="uid://bq5oqyuwekryv" path="res://materials/building_block.tres" id="12_i3ahj"]
|
[ext_resource type="Material" uid="uid://bq5oqyuwekryv" path="res://materials/building_block.tres" id="12_i3ahj"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://b5asfx4vribls" path="res://scenes/interface/hud.tscn" id="7_g7tfv"]
|
||||||
|
|
||||||
[node name="Demo" type="Node3D"]
|
[node name="Demo" type="Node3D"]
|
||||||
|
|
||||||
@ -53,14 +54,12 @@ size = Vector3(43.3174, 26.5295, 43.4319)
|
|||||||
[node name="Player" parent="." instance=ExtResource("10_3xiy2")]
|
[node name="Player" parent="." instance=ExtResource("10_3xiy2")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.332064, 1.5426, 3.65156)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.332064, 1.5426, 3.65156)
|
||||||
|
|
||||||
|
[node name="table" parent="." node_paths=PackedStringArray("TrenchbroomMap") instance=ExtResource("11_7trvw")]
|
||||||
|
transform = Transform3D(-0.0123217, 0, 0.999924, 0, 1, 0, -0.999924, 0, -0.0123217, 2.83695, 0, -4.36558)
|
||||||
|
TrenchbroomMap = NodePath("../DemoMap")
|
||||||
|
RelativeScale = 0.005
|
||||||
|
|
||||||
|
[node name="HUD" parent="." node_paths=PackedStringArray("Player") instance=ExtResource("7_g7tfv")]
|
||||||
|
Player = NodePath("../Player")
|
||||||
|
|
||||||
[node name="PauseMenu" parent="." instance=ExtResource("11_lav3p")]
|
[node name="PauseMenu" parent="." instance=ExtResource("11_lav3p")]
|
||||||
|
|
||||||
[node name="table" parent="." instance=ExtResource("11_7trvw")]
|
|
||||||
transform = Transform3D(-0.0123217, 0, 0.999924, 0, 1, 0, -0.999924, 0, -0.0123217, 0, 0, 0)
|
|
||||||
|
|
||||||
[node name="Node3D" parent="table" index="2" node_paths=PackedStringArray("TrenchbroomMap")]
|
|
||||||
TrenchbroomMap = NodePath("../../DemoMap")
|
|
||||||
BuildingBlockMaterial = ExtResource("12_i3ahj")
|
|
||||||
BuildingBlockScale = 0.005
|
|
||||||
|
|
||||||
[editable path="table"]
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
[gd_scene load_steps=135 format=4 uid="uid://d4fn0ljcmjdnb"]
|
[gd_scene load_steps=135 format=4 uid="uid://bqts60gpnb82d"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://addons/func_godot/src/map/func_godot_map.gd" id="1_2fyf3"]
|
[ext_resource type="Script" path="res://addons/func_godot/src/map/func_godot_map.gd" id="1_2fyf3"]
|
||||||
[ext_resource type="Resource" uid="uid://byyagd41ivbt1" path="res://trenchbroom/map_settings.tres" id="2_bv511"]
|
[ext_resource type="Resource" uid="uid://byyagd41ivbt1" path="res://trenchbroom/map_settings.tres" id="2_bv511"]
|
||||||
[ext_resource type="Material" uid="uid://bpikku6t3gxi5" path="res://textures/white.tres" id="3_lw60r"]
|
[ext_resource type="Material" uid="uid://bpikku6t3gxi5" path="res://materials/white.tres" id="3_lw60r"]
|
||||||
[ext_resource type="Material" uid="uid://cobb5bm4y7nk7" path="res://textures/steel.tres" id="4_ae80v"]
|
[ext_resource type="Material" uid="uid://cobb5bm4y7nk7" path="res://materials/steel.tres" id="4_ae80v"]
|
||||||
[ext_resource type="Material" uid="uid://dgf570wtqn17j" path="res://textures/steel_fence.tres" id="5_jlrhq"]
|
[ext_resource type="Material" uid="uid://dgf570wtqn17j" path="res://materials/steel_fence.tres" id="5_jlrhq"]
|
||||||
|
|
||||||
[sub_resource type="ArrayMesh" id="ArrayMesh_wgnqo"]
|
[sub_resource type="ArrayMesh" id="ArrayMesh_wgnqo"]
|
||||||
lightmap_size_hint = Vector2i(1234, 1226)
|
lightmap_size_hint = Vector2i(1234, 1226)
|
||||||
|
51
scenes/interface/hud.tscn
Normal file
51
scenes/interface/hud.tscn
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
[gd_scene load_steps=2 format=3 uid="uid://b5asfx4vribls"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scripts/Hud.cs" id="1_hvqpl"]
|
||||||
|
|
||||||
|
[node name="HUD" type="Control" node_paths=PackedStringArray("HoverText")]
|
||||||
|
layout_mode = 3
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
mouse_filter = 2
|
||||||
|
script = ExtResource("1_hvqpl")
|
||||||
|
HoverText = NodePath("HoverText")
|
||||||
|
|
||||||
|
[node name="HoverText" type="RichTextLabel" parent="."]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 7
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 1.0
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
offset_left = -94.0
|
||||||
|
offset_top = -163.0
|
||||||
|
offset_right = 95.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 0
|
||||||
|
theme_override_font_sizes/normal_font_size = 32
|
||||||
|
bbcode_enabled = true
|
||||||
|
text = "[Hover Text]"
|
||||||
|
fit_content = true
|
||||||
|
scroll_active = false
|
||||||
|
autowrap_mode = 0
|
||||||
|
|
||||||
|
[node name="CenterContainer" type="CenterContainer" parent="."]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
|
||||||
|
[node name="ColorRect" type="ColorRect" parent="CenterContainer"]
|
||||||
|
custom_minimum_size = Vector2(16, 2)
|
||||||
|
layout_mode = 2
|
||||||
|
mouse_filter = 1
|
||||||
|
|
||||||
|
[node name="ColorRect2" type="ColorRect" parent="CenterContainer"]
|
||||||
|
custom_minimum_size = Vector2(2, 16)
|
||||||
|
layout_mode = 2
|
||||||
|
mouse_filter = 1
|
@ -8,7 +8,7 @@
|
|||||||
height = 1.9
|
height = 1.9
|
||||||
radius = 0.3
|
radius = 0.3
|
||||||
|
|
||||||
[node name="Player" type="CharacterBody3D" node_paths=PackedStringArray("Eye", "HeightBasedWindPlayer", "FootstepPlayer")]
|
[node name="Player" type="CharacterBody3D" node_paths=PackedStringArray("Eye", "LookingAt", "HeightBasedWindPlayer", "FootstepPlayer")]
|
||||||
floor_block_on_wall = false
|
floor_block_on_wall = false
|
||||||
floor_snap_length = 0.25
|
floor_snap_length = 0.25
|
||||||
script = ExtResource("1_aff2a")
|
script = ExtResource("1_aff2a")
|
||||||
@ -16,6 +16,7 @@ MovementSpeed = 4.0
|
|||||||
JumpVelocity = 6.0
|
JumpVelocity = 6.0
|
||||||
Gravity = 13.0
|
Gravity = 13.0
|
||||||
Eye = NodePath("PlayerEyeCamera")
|
Eye = NodePath("PlayerEyeCamera")
|
||||||
|
LookingAt = NodePath("PlayerEyeCamera/LookAt")
|
||||||
HeightBasedWindPlayer = NodePath("HeightBasedWindFx")
|
HeightBasedWindPlayer = NodePath("HeightBasedWindFx")
|
||||||
MinVolumeWindHeight = -5.0
|
MinVolumeWindHeight = -5.0
|
||||||
MaxVolumeWindHeight = 20.0
|
MaxVolumeWindHeight = 20.0
|
||||||
@ -28,27 +29,16 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.7, 0)
|
|||||||
[node name="Ears" type="AudioListener3D" parent="PlayerEyeCamera"]
|
[node name="Ears" type="AudioListener3D" parent="PlayerEyeCamera"]
|
||||||
current = true
|
current = true
|
||||||
|
|
||||||
|
[node name="LookAt" type="RayCast3D" parent="PlayerEyeCamera"]
|
||||||
|
target_position = Vector3(0, 0, -4)
|
||||||
|
collision_mask = 4
|
||||||
|
debug_shape_custom_color = Color(1, 1, 1, 1)
|
||||||
|
debug_shape_thickness = 5
|
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.95, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.95, 0)
|
||||||
shape = SubResource("CylinderShape3D_rgktv")
|
shape = SubResource("CylinderShape3D_rgktv")
|
||||||
|
|
||||||
[node name="CenterContainer" type="CenterContainer" parent="."]
|
|
||||||
anchors_preset = 15
|
|
||||||
anchor_right = 1.0
|
|
||||||
anchor_bottom = 1.0
|
|
||||||
grow_horizontal = 2
|
|
||||||
grow_vertical = 2
|
|
||||||
|
|
||||||
[node name="ColorRect" type="ColorRect" parent="CenterContainer"]
|
|
||||||
custom_minimum_size = Vector2(16, 2)
|
|
||||||
layout_mode = 2
|
|
||||||
mouse_filter = 1
|
|
||||||
|
|
||||||
[node name="ColorRect2" type="ColorRect" parent="CenterContainer"]
|
|
||||||
custom_minimum_size = Vector2(2, 16)
|
|
||||||
layout_mode = 2
|
|
||||||
mouse_filter = 1
|
|
||||||
|
|
||||||
[node name="HeightBasedWindFx" type="AudioStreamPlayer" parent="."]
|
[node name="HeightBasedWindFx" type="AudioStreamPlayer" parent="."]
|
||||||
process_mode = 3
|
process_mode = 3
|
||||||
stream = ExtResource("2_ab4w4")
|
stream = ExtResource("2_ab4w4")
|
||||||
|
@ -1,21 +1,79 @@
|
|||||||
[gd_scene load_steps=4 format=3 uid="uid://d02cqylu3xwos"]
|
[gd_scene load_steps=10 format=3 uid="uid://d02cqylu3xwos"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://diwlyi146eroa" path="res://models/table.fbx" id="1_1soa3"]
|
[ext_resource type="PackedScene" uid="uid://diwlyi146eroa" path="res://models/table.fbx" id="1_1soa3"]
|
||||||
[ext_resource type="Script" path="res://scripts/BuildingBlockCreator.cs" id="2_rqgiy"]
|
[ext_resource type="Script" path="res://scripts/Table.cs" id="1_cb7s1"]
|
||||||
|
[ext_resource type="Material" uid="uid://bq5oqyuwekryv" path="res://materials/building_block.tres" id="2_1s35y"]
|
||||||
|
[ext_resource type="Material" uid="uid://pu02smf107o8" path="res://materials/building_block_hover.tres" id="3_m64id"]
|
||||||
|
[ext_resource type="Script" path="res://scripts/Orbit.cs" id="4_nyqjn"]
|
||||||
|
|
||||||
[sub_resource type="BoxShape3D" id="BoxShape3D_iiew7"]
|
[sub_resource type="BoxShape3D" id="BoxShape3D_iiew7"]
|
||||||
size = Vector3(1.26587, 0.102112, 2.3989)
|
size = Vector3(1.26587, 1.10037, 2.3989)
|
||||||
|
|
||||||
[node name="table" type="StaticBody3D"]
|
[sub_resource type="BoxShape3D" id="BoxShape3D_kn6mn"]
|
||||||
collision_layer = 2
|
size = Vector3(5, 5, 5)
|
||||||
collision_mask = 2
|
|
||||||
|
[sub_resource type="BoxShape3D" id="BoxShape3D_5k7xn"]
|
||||||
|
size = Vector3(5, 5, 5)
|
||||||
|
|
||||||
|
[sub_resource type="BoxShape3D" id="BoxShape3D_3kmm7"]
|
||||||
|
size = Vector3(1.3, 0.2, 2.4)
|
||||||
|
|
||||||
|
[node name="table" type="RigidBody3D" node_paths=PackedStringArray("SpawnPoint", "Orbit")]
|
||||||
|
collision_layer = 7
|
||||||
|
collision_mask = 7
|
||||||
|
lock_rotation = true
|
||||||
|
freeze = true
|
||||||
|
script = ExtResource("1_cb7s1")
|
||||||
|
BlockMaterial = ExtResource("2_1s35y")
|
||||||
|
BlockHoverMaterial = ExtResource("3_m64id")
|
||||||
|
SpawnPoint = NodePath("SpawnPoint")
|
||||||
|
BlockMask = 10
|
||||||
|
Orbit = NodePath("Orbit")
|
||||||
|
InteractName = "build"
|
||||||
|
|
||||||
[node name="table" parent="." instance=ExtResource("1_1soa3")]
|
[node name="table" parent="." instance=ExtResource("1_1soa3")]
|
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
[node name="TableCollider" type="CollisionShape3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.00354004, 1.05606, -0.00126699)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.00354004, 0.55693, -0.00126699)
|
||||||
shape = SubResource("BoxShape3D_iiew7")
|
shape = SubResource("BoxShape3D_iiew7")
|
||||||
|
|
||||||
[node name="Node3D" type="Node3D" parent="."]
|
[node name="SpawnPoint" type="Node3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3.58235, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.7677, 0)
|
||||||
script = ExtResource("2_rqgiy")
|
|
||||||
|
[node name="TableWalls" type="StaticBody3D" parent="."]
|
||||||
|
collision_layer = 2
|
||||||
|
collision_mask = 2
|
||||||
|
|
||||||
|
[node name="Wall1" type="CollisionShape3D" parent="TableWalls"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3.6, 3.66627)
|
||||||
|
shape = SubResource("BoxShape3D_kn6mn")
|
||||||
|
|
||||||
|
[node name="Wall2" type="CollisionShape3D" parent="TableWalls"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3.6, -3.69933)
|
||||||
|
shape = SubResource("BoxShape3D_kn6mn")
|
||||||
|
|
||||||
|
[node name="Wall3" type="CollisionShape3D" parent="TableWalls"]
|
||||||
|
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, -3.1173, 3.6, 0)
|
||||||
|
shape = SubResource("BoxShape3D_5k7xn")
|
||||||
|
|
||||||
|
[node name="Wall4" type="CollisionShape3D" parent="TableWalls"]
|
||||||
|
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 3.1173, 3.6, 0)
|
||||||
|
shape = SubResource("BoxShape3D_5k7xn")
|
||||||
|
|
||||||
|
[node name="Roof" type="CollisionShape3D" parent="TableWalls"]
|
||||||
|
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 6, 0)
|
||||||
|
shape = SubResource("BoxShape3D_3kmm7")
|
||||||
|
|
||||||
|
[node name="Orbit" type="Node3D" parent="." node_paths=PackedStringArray("Camera", "Hand")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.12311, 0)
|
||||||
|
script = ExtResource("4_nyqjn")
|
||||||
|
Camera = NodePath("OrbitCamera")
|
||||||
|
Hand = NodePath("OrbitCamera/OrbitHand")
|
||||||
|
|
||||||
|
[node name="OrbitCamera" type="Camera3D" parent="Orbit"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1)
|
||||||
|
|
||||||
|
[node name="OrbitHand" type="Node3D" parent="Orbit/OrbitCamera"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.3, -0.1, -0.26)
|
||||||
|
|
||||||
|
[connection signal="Interacted" from="." to="." method="Interact"]
|
||||||
|
144
scripts/BuildingBlock.cs
Normal file
144
scripts/BuildingBlock.cs
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
using Godot;
|
||||||
|
using Godot.Collections;
|
||||||
|
|
||||||
|
namespace Gmtk24 {
|
||||||
|
public partial class BuildingBlock : Interactible {
|
||||||
|
[Signal]
|
||||||
|
public delegate void PickUpEventHandler(BuildingBlock block);
|
||||||
|
|
||||||
|
public BaseBlock Base;
|
||||||
|
public ShaderMaterial Material;
|
||||||
|
public ShaderMaterial HoverMaterial;
|
||||||
|
public float RelativeScale;
|
||||||
|
public uint PhysicalModeLayer;
|
||||||
|
|
||||||
|
public BlockMode Mode { private set; get; } = BlockMode.Physical;
|
||||||
|
|
||||||
|
private MeshInstance3D MeshInstance;
|
||||||
|
|
||||||
|
private ShaderMaterial[] NormalMaterialArr;
|
||||||
|
private ShaderMaterial[] HoverMaterialArr;
|
||||||
|
|
||||||
|
public BuildingBlock() {
|
||||||
|
Name = "BuildingBlock";
|
||||||
|
FreezeMode = FreezeModeEnum.Kinematic;
|
||||||
|
CanSleep = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void _Ready() {
|
||||||
|
base._Ready();
|
||||||
|
|
||||||
|
UpdatePhysics();
|
||||||
|
|
||||||
|
HoverMaterial ??= Material;
|
||||||
|
|
||||||
|
Hovered += OnHover;
|
||||||
|
Interacted += OnInteract;
|
||||||
|
|
||||||
|
MeshInstance = new MeshInstance3D() {
|
||||||
|
Mesh = Base.Mesh,
|
||||||
|
Scale = Vector3.One * RelativeScale,
|
||||||
|
};
|
||||||
|
AddChild(MeshInstance);
|
||||||
|
|
||||||
|
int count = MeshInstance.GetSurfaceOverrideMaterialCount();
|
||||||
|
|
||||||
|
NormalMaterialArr = new ShaderMaterial[count];
|
||||||
|
HoverMaterialArr = new ShaderMaterial[count];
|
||||||
|
|
||||||
|
for (int i = 0; i < MeshInstance.GetSurfaceOverrideMaterialCount(); i++) {
|
||||||
|
var replacedMaterial = MeshInstance.Mesh.SurfaceGetMaterial(i);
|
||||||
|
var transparency = replacedMaterial.Get("transparency");
|
||||||
|
if (((int)transparency) != 0) {
|
||||||
|
ShaderMaterial newMat = (ShaderMaterial)Material.Duplicate();
|
||||||
|
newMat.SetShaderParameter("texture_albedo_for_alpha", replacedMaterial.Get("albedo_texture"));
|
||||||
|
|
||||||
|
ShaderMaterial newHoverMat = (ShaderMaterial)HoverMaterial.Duplicate();
|
||||||
|
newHoverMat.SetShaderParameter("texture_albedo_for_alpha", replacedMaterial.Get("albedo_texture"));
|
||||||
|
|
||||||
|
NormalMaterialArr[i] = newMat;
|
||||||
|
HoverMaterialArr[i] = newHoverMat;
|
||||||
|
} else {
|
||||||
|
NormalMaterialArr[i] = Material;
|
||||||
|
}
|
||||||
|
MeshInstance.SetSurfaceOverrideMaterial(i, NormalMaterialArr[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var shape in Base.Colliders) {
|
||||||
|
var bigPoints = ((ConvexPolygonShape3D)shape.Shape).Points;
|
||||||
|
var points = new Vector3[bigPoints.Length];
|
||||||
|
for (int i = 0; i < bigPoints.Length; i++) {
|
||||||
|
points[i] = bigPoints[i] * RelativeScale;
|
||||||
|
}
|
||||||
|
AddChild(new CollisionShape3D {
|
||||||
|
Shape = new ConvexPolygonShape3D {
|
||||||
|
Points = points,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetMode(BlockMode mode) {
|
||||||
|
GD.Print(mode);
|
||||||
|
Mode = mode;
|
||||||
|
SetMaterial(false);
|
||||||
|
UpdatePhysics();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdatePhysics() {
|
||||||
|
if (Mode != BlockMode.NonPhysical) {
|
||||||
|
CollisionLayer = PhysicalModeLayer;
|
||||||
|
CollisionMask = PhysicalModeLayer;
|
||||||
|
if (Mode == BlockMode.Dragged) {
|
||||||
|
FreezeMode = FreezeModeEnum.Kinematic;
|
||||||
|
Freeze = true;
|
||||||
|
} else {
|
||||||
|
Freeze = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
CollisionLayer = 0;
|
||||||
|
CollisionMask = 0;
|
||||||
|
FreezeMode = FreezeModeEnum.Static;
|
||||||
|
Freeze = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnHover(bool hovered) {
|
||||||
|
if (Mode != BlockMode.NonPhysical) {
|
||||||
|
SetMaterial(hovered);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetMaterial(bool hoverMaterial) {
|
||||||
|
for (int i = 0; i < MeshInstance.GetSurfaceOverrideMaterialCount(); i++) {
|
||||||
|
if (hoverMaterial)
|
||||||
|
MeshInstance.SetSurfaceOverrideMaterial(i, HoverMaterialArr[i]);
|
||||||
|
else
|
||||||
|
MeshInstance.SetSurfaceOverrideMaterial(i, NormalMaterialArr[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnInteract(InputEvent _) {
|
||||||
|
EmitSignal(SignalName.PickUp, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct BaseBlock {
|
||||||
|
public Mesh Mesh;
|
||||||
|
public Array<CollisionShape3D> Colliders;
|
||||||
|
|
||||||
|
public BaseBlock(StaticBody3D reference) {
|
||||||
|
Mesh = ((MeshInstance3D)reference.FindChild("*_mesh_instance")).Mesh;
|
||||||
|
Colliders = new Array<CollisionShape3D>();
|
||||||
|
foreach (var shape in reference.FindChildren("*_collision_shape")) {
|
||||||
|
Colliders.Add((CollisionShape3D)shape);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum BlockMode {
|
||||||
|
Physical,
|
||||||
|
Dragged,
|
||||||
|
NonPhysical,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,64 +0,0 @@
|
|||||||
using Godot;
|
|
||||||
|
|
||||||
namespace Gmtk24 {
|
|
||||||
public partial class BuildingBlockCreator : Node3D {
|
|
||||||
[Export]
|
|
||||||
public Node3D TrenchbroomMap;
|
|
||||||
// [Export]
|
|
||||||
// public PackedScene BuildingBlockPrefab;
|
|
||||||
[Export]
|
|
||||||
public ShaderMaterial BuildingBlockMaterial;
|
|
||||||
[Export]
|
|
||||||
public float BuildingBlockScale = 0.05f;
|
|
||||||
|
|
||||||
public override void _Ready() {
|
|
||||||
var children = TrenchbroomMap.FindChildren("*_buildingblock");
|
|
||||||
foreach (var buildingBlockStaticBody in children) {
|
|
||||||
var buildingBlock = new RigidBody3D() {
|
|
||||||
CollisionMask = 0b10,
|
|
||||||
CollisionLayer = 0b10,
|
|
||||||
};
|
|
||||||
|
|
||||||
var smallMesh = new MeshInstance3D {
|
|
||||||
Mesh = buildingBlockStaticBody.GetChild<MeshInstance3D>(0).Mesh,
|
|
||||||
Scale = Vector3.One * BuildingBlockScale,
|
|
||||||
};
|
|
||||||
for (int i = 0; i < smallMesh.GetSurfaceOverrideMaterialCount(); i++) {
|
|
||||||
var replacedMaterial = smallMesh.Mesh.SurfaceGetMaterial(i);
|
|
||||||
var transparency = replacedMaterial.Get("transparency");
|
|
||||||
if (((int)transparency) != 0) {
|
|
||||||
// Make a new material, using the partly-transparent albedo as an alpha mask
|
|
||||||
var blockMaterialWithAlphaMask = (ShaderMaterial)BuildingBlockMaterial.Duplicate();
|
|
||||||
blockMaterialWithAlphaMask.SetShaderParameter("texture_albedo_for_alpha", replacedMaterial.Get("albedo_texture"));
|
|
||||||
smallMesh.SetSurfaceOverrideMaterial(i, blockMaterialWithAlphaMask);
|
|
||||||
} else {
|
|
||||||
smallMesh.SetSurfaceOverrideMaterial(i, BuildingBlockMaterial);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
buildingBlock.AddChild(smallMesh);
|
|
||||||
|
|
||||||
var collisionShapes = buildingBlockStaticBody.FindChildren("*_collision_shape");
|
|
||||||
foreach (var shape in collisionShapes) {
|
|
||||||
var bigPoints = ((ConvexPolygonShape3D)((CollisionShape3D)shape).Shape).Points;
|
|
||||||
var points = new Vector3[bigPoints.Length];
|
|
||||||
for (int i = 0; i < bigPoints.Length; i++) {
|
|
||||||
points[i] = bigPoints[i] * BuildingBlockScale;
|
|
||||||
}
|
|
||||||
buildingBlock.AddChild(new CollisionShape3D {
|
|
||||||
Shape = new ConvexPolygonShape3D {
|
|
||||||
Points = points,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
AddChild(buildingBlock);
|
|
||||||
var rng = new RandomNumberGenerator();
|
|
||||||
buildingBlock.Translate(Vector3.One * rng.Randf() * 0.5f);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void _Process(double delta) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
54
scripts/Hud.cs
Normal file
54
scripts/Hud.cs
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
using Godot;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Gmtk24 {
|
||||||
|
public partial class Hud : Control {
|
||||||
|
[Export]
|
||||||
|
public Player Player;
|
||||||
|
[Export]
|
||||||
|
public RichTextLabel HoverText;
|
||||||
|
|
||||||
|
private Interactible Hovered;
|
||||||
|
|
||||||
|
public override void _Process(double delta) {
|
||||||
|
if (Player == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
GodotObject collider = null;
|
||||||
|
if (Input.MouseMode == Input.MouseModeEnum.Captured) {
|
||||||
|
if (Player.Eye.Current)
|
||||||
|
collider = Player.LookingAt.GetCollider();
|
||||||
|
} else {
|
||||||
|
var results = Util.RaycastFromMouse(GetViewport().GetCamera3D());
|
||||||
|
collider = results?.Collider;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (collider is Interactible interactible) {
|
||||||
|
if (interactible != Hovered) {
|
||||||
|
Hovered?.SetHovered(false);
|
||||||
|
interactible.SetHovered(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
Hovered = interactible;
|
||||||
|
|
||||||
|
StringBuilder Builder = new StringBuilder();
|
||||||
|
foreach (var e in InputMap.ActionGetEvents("interact")) {
|
||||||
|
Builder.Append($"{e.AsText().Replace("(Physical)", "")}: {interactible.InteractName}");
|
||||||
|
}
|
||||||
|
|
||||||
|
HoverText.Text = Builder.ToString();
|
||||||
|
} else {
|
||||||
|
Hovered?.SetHovered(false);
|
||||||
|
Hovered = null;
|
||||||
|
HoverText.Text = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void _UnhandledInput(InputEvent @event) {
|
||||||
|
if (@event.IsAction("interact") && Hovered != null) {
|
||||||
|
Hovered.HandleInput(@event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
23
scripts/Interactible.cs
Normal file
23
scripts/Interactible.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
|
||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace Gmtk24 {
|
||||||
|
public partial class Interactible : RigidBody3D {
|
||||||
|
[Signal]
|
||||||
|
public delegate void InteractedEventHandler(InputEvent e);
|
||||||
|
[Signal]
|
||||||
|
public delegate void HoveredEventHandler(bool hovered);
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
public string InteractName;
|
||||||
|
|
||||||
|
public void HandleInput(InputEvent e) {
|
||||||
|
if (e.IsPressed())
|
||||||
|
EmitSignal(SignalName.Interacted, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetHovered(bool hovered) {
|
||||||
|
EmitSignal(SignalName.Hovered, hovered);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
90
scripts/Orbit.cs
Normal file
90
scripts/Orbit.cs
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
using Godot;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Gmtk24 {
|
||||||
|
public partial class Orbit : Node3D {
|
||||||
|
[Export(PropertyHint.Range, "0,10,0.1")]
|
||||||
|
public float MaxCameraDistance = 1f;
|
||||||
|
[Export(PropertyHint.Range, "0,10,0.1")]
|
||||||
|
public float MinCameraDistance = 0.1f;
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
public Camera3D Camera;
|
||||||
|
[Export]
|
||||||
|
public Node3D Hand;
|
||||||
|
[Export]
|
||||||
|
public BuildingBlock HeldBlock { private set; get; }
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
public bool IsEnabled { private set; get; } = false;
|
||||||
|
|
||||||
|
private float CurrentYaw = 0;
|
||||||
|
private float CurrentPitch = 0;
|
||||||
|
|
||||||
|
// Called when the node enters the scene tree for the first time.
|
||||||
|
public override void _Ready() {
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
public override void _Process(double delta) {
|
||||||
|
Quaternion = new Quaternion(Vector3.Up, CurrentYaw) * new Quaternion(Vector3.Right, CurrentPitch);
|
||||||
|
if (HeldBlock != null)
|
||||||
|
HeldBlock.Position = HeldBlock.Position.Lerp(Vector3.Zero, 0.2f);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetEnabled(bool enabled) {
|
||||||
|
IsEnabled = enabled;
|
||||||
|
Camera.Current = enabled;
|
||||||
|
if (IsEnabled)
|
||||||
|
Input.MouseMode = Input.MouseModeEnum.Visible;
|
||||||
|
else
|
||||||
|
Input.MouseMode = Input.MouseModeEnum.Captured;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void _UnhandledInput(InputEvent @event) {
|
||||||
|
if (!IsEnabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (@event.IsActionPressed("drag_orbit"))
|
||||||
|
Input.MouseMode = Input.MouseModeEnum.Captured;
|
||||||
|
if (@event.IsActionReleased("drag_orbit"))
|
||||||
|
Input.MouseMode = Input.MouseModeEnum.Visible;
|
||||||
|
|
||||||
|
if (Input.IsActionPressed("drag_orbit") && @event is InputEventMouseMotion mouseMotion) {
|
||||||
|
var cameraSensitivity = UserSettings.Singleton.GetCameraSpeedMultipliers();
|
||||||
|
var mouseMultiplier = 0.0003f;
|
||||||
|
CurrentYaw -= mouseMotion.ScreenRelative.X * mouseMultiplier * cameraSensitivity.X;
|
||||||
|
CurrentPitch -= mouseMotion.ScreenRelative.Y * mouseMultiplier * cameraSensitivity.Y;
|
||||||
|
|
||||||
|
CurrentPitch = Mathf.Clamp(CurrentPitch, -Mathf.Pi * 0.49f, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (@event.IsActionPressed("release_block")) {
|
||||||
|
HeldBlock.SetMode(BuildingBlock.BlockMode.Physical);
|
||||||
|
HeldBlock.Reparent(GetParent());
|
||||||
|
var normal = Camera.ProjectRayNormal(Camera.GetViewport().GetMousePosition());
|
||||||
|
var direction = normal * 10;
|
||||||
|
|
||||||
|
var res = Util.RaycastFromMouse(Camera, 0b1111);
|
||||||
|
if (res is RaycastResult results) {
|
||||||
|
GD.Print(results.Position);
|
||||||
|
direction = (results.Position - HeldBlock.GlobalPosition + Vector3.Up * 0.5f) * 3;
|
||||||
|
}
|
||||||
|
HeldBlock.ApplyImpulse(direction);
|
||||||
|
|
||||||
|
HeldBlock = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HoldBlock(BuildingBlock block) {
|
||||||
|
if (HeldBlock != null)
|
||||||
|
return false; // TODO
|
||||||
|
|
||||||
|
HeldBlock = block;
|
||||||
|
HeldBlock.SetMode(BuildingBlock.BlockMode.NonPhysical);
|
||||||
|
HeldBlock.Reparent(Hand, true);
|
||||||
|
HeldBlock.Rotation = Vector3.Zero;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,7 @@ using Godot;
|
|||||||
|
|
||||||
namespace Gmtk24 {
|
namespace Gmtk24 {
|
||||||
public partial class Player : CharacterBody3D {
|
public partial class Player : CharacterBody3D {
|
||||||
|
[ExportCategory("Movement")]
|
||||||
[Export]
|
[Export]
|
||||||
public float MovementSpeed = 7;
|
public float MovementSpeed = 7;
|
||||||
[Export]
|
[Export]
|
||||||
@ -12,8 +13,11 @@ namespace Gmtk24 {
|
|||||||
public float JumpBufferLengthSeconds = 0.2f;
|
public float JumpBufferLengthSeconds = 0.2f;
|
||||||
[Export]
|
[Export]
|
||||||
public float Gravity = 20;
|
public float Gravity = 20;
|
||||||
|
[ExportCategory("Vision")]
|
||||||
[Export]
|
[Export]
|
||||||
public Node3D Eye;
|
public Camera3D Eye;
|
||||||
|
[Export]
|
||||||
|
public RayCast3D LookingAt;
|
||||||
[ExportCategory("Noises")]
|
[ExportCategory("Noises")]
|
||||||
[Export]
|
[Export]
|
||||||
public AudioStreamPlayer HeightBasedWindPlayer;
|
public AudioStreamPlayer HeightBasedWindPlayer;
|
||||||
|
@ -0,0 +1,64 @@
|
|||||||
|
using Godot;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace Gmtk24 {
|
||||||
|
public partial class Table : Interactible {
|
||||||
|
[Export(PropertyHint.NodeType, "FuncGodotMap")]
|
||||||
|
public Node3D TrenchbroomMap;
|
||||||
|
[Export(PropertyHint.Range, "0.005,0.1,0.005,or_greater")]
|
||||||
|
public float RelativeScale = 0.05f;
|
||||||
|
[Export]
|
||||||
|
public ShaderMaterial BlockMaterial;
|
||||||
|
[Export]
|
||||||
|
public ShaderMaterial BlockHoverMaterial;
|
||||||
|
[Export]
|
||||||
|
public Node3D SpawnPoint;
|
||||||
|
[Export(PropertyHint.LayersAvoidance)]
|
||||||
|
public uint BlockMask;
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
public Orbit Orbit;
|
||||||
|
|
||||||
|
// Called when the node enters the scene tree for the first time.
|
||||||
|
public override void _Ready() {
|
||||||
|
Vector3 SpawnPos = Vector3.Zero;
|
||||||
|
|
||||||
|
if (SpawnPoint != null)
|
||||||
|
SpawnPos = SpawnPoint.GlobalPosition - GlobalPosition;
|
||||||
|
|
||||||
|
SpawnBlocks(SpawnPos);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SpawnBlocks(Vector3 position) {
|
||||||
|
var rng = new RandomNumberGenerator();
|
||||||
|
|
||||||
|
var children = TrenchbroomMap.FindChildren("*_buildingblock");
|
||||||
|
foreach (StaticBody3D buildingBlockStaticBody in children.Cast<StaticBody3D>()) {
|
||||||
|
|
||||||
|
var baseBlock = new BuildingBlock.BaseBlock(buildingBlockStaticBody);
|
||||||
|
|
||||||
|
var block = new BuildingBlock() {
|
||||||
|
Base = baseBlock,
|
||||||
|
Material = BlockMaterial,
|
||||||
|
HoverMaterial = BlockHoverMaterial,
|
||||||
|
Position = position + Vector3.One * (rng.Randf() * 0.5f - 0.25f) + Vector3.Up * rng.Randf(),
|
||||||
|
PhysicalModeLayer = BlockMask,
|
||||||
|
RelativeScale = RelativeScale,
|
||||||
|
};
|
||||||
|
|
||||||
|
AddChild(block);
|
||||||
|
|
||||||
|
block.PickUp += OnBlockPickup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Interact(InputEvent _) {
|
||||||
|
Orbit.SetEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnBlockPickup(BuildingBlock block) {
|
||||||
|
Orbit.HoldBlock(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
36
scripts/Util.cs
Normal file
36
scripts/Util.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
|
||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace Gmtk24 {
|
||||||
|
public static class Util {
|
||||||
|
public static RaycastResult? RaycastFromMouse(Camera3D camera, uint mask = 0b1000) {
|
||||||
|
var viewport = camera.GetViewport();
|
||||||
|
var origin = camera.ProjectRayOrigin(viewport.GetMousePosition());
|
||||||
|
var normal = camera.ProjectRayNormal(viewport.GetMousePosition()) * 10000;
|
||||||
|
var ray = new PhysicsRayQueryParameters3D {
|
||||||
|
From = origin,
|
||||||
|
To = normal,
|
||||||
|
CollideWithBodies = true,
|
||||||
|
CollisionMask = mask,
|
||||||
|
HitBackFaces = false,
|
||||||
|
HitFromInside = false,
|
||||||
|
};
|
||||||
|
var results = camera.GetWorld3D().DirectSpaceState.IntersectRay(ray);
|
||||||
|
if (results.ContainsKey("position")) {
|
||||||
|
return new RaycastResult() {
|
||||||
|
Collider = (GodotObject)results["collider"],
|
||||||
|
Position = (Vector3)results["position"],
|
||||||
|
Normal = (Vector3)results["normal"],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct RaycastResult {
|
||||||
|
public Vector3 Position;
|
||||||
|
public Vector3 Normal;
|
||||||
|
public GodotObject Collider;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user