Detect tile under foot

This commit is contained in:
YourWishes committed 2025-01-02 21:36:24 -06:00
1 parent 95b13a7f55
commit 4303aafb59
11 files changed
+84 -54

No files matched your search

BIN
View File
Binary file not shown.
Binary file not shown.
+3 -4
View File
@@ -9,11 +9,10 @@ render_priority = 0
shader = ExtResource("2_wvm2e")
shader_parameter/tileset = ExtResource("3_pxeo7")
[sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_jxgrq"]
data = PackedVector3Array(-1.5001, -0.0001, 1.4996, -0.0001, -0.0001, 2.9995, -1.5001, -0.0001, 2.9995, -1.5001, -0.0001, 1.4996, -0.0001, -0.0001, 1.4996, -0.0001, -0.0001, 2.9995, -1.5001, -0.0001, -1.5001, -0.0001, -0.0001, -0.0003, -1.5001, -0.0001, -0.0003, -1.5001, -0.0001, -1.5001, -0.0001, -0.0001, -1.5001, -0.0001, -0.0001, -0.0003, -0.0001, -0.0001, -1.5001, 1.4999, -0.0001, -0.0003, -0.0001, -0.0001, -0.0003, -0.0001, -0.0001, -1.5001, 1.4999, -0.0001, -1.5001, 1.4999, -0.0001, -0.0003, -0.0001, -0.0001, -0.0003, 1.4999, -0.0001, 1.4996, -0.0001, -0.0001, 1.4996, -0.0001, -0.0001, -0.0003, 1.4999, -0.0001, -0.0003, 1.4999, -0.0001, 1.4996, -0.0001, -0.0001, 1.4996, 1.4999, -0.0001, 2.9995, -0.0001, -0.0001, 2.9995, -0.0001, -0.0001, 1.4996, 1.4999, -0.0001, 1.4996, 1.4999, -0.0001, 2.9995, -1.5001, -0.0001, -0.0003, -0.0001, -0.0001, 1.4996, -1.5001, -0.0001, 1.4996, -1.5001, -0.0001, -0.0003, -0.0001, -0.0001, -0.0003, -0.0001, -0.0001, 1.4996, 1.4999, -0.0001, 1.4996, 3, -0.0001, 2.9995, 1.4999, -0.0001, 2.9995, 1.4999, -0.0001, 1.4996, 3, -0.0001, 1.4996, 3, -0.0001, 2.9995, 1.4999, -0.0001, -0.0003, 3, -0.0001, 1.4996, 1.4999, -0.0001, 1.4996, 1.4999, -0.0001, -0.0003, 3, -0.0001, -0.0003, 3, -0.0001, 1.4996, 1.4999, -0.0001, -1.5001, 3, -0.0001, -0.0003, 1.4999, -0.0001, -0.0003, 1.4999, -0.0001, -1.5001, 3, -0.0001, -1.5001, 3, -0.0001, -0.0003, 1.4999, -0.0001, -3, 3, -0.0001, -1.5001, 1.4999, -0.0001, -1.5001, 1.4999, -0.0001, -3, 3, -0.0001, -3, 3, -0.0001, -1.5001, -0.0001, -0.0001, -3, 1.4999, -0.0001, -1.5001, -0.0001, -0.0001, -1.5001, -0.0001, -0.0001, -3, 1.4999, -0.0001, -3, 1.4999, -0.0001, -1.5001, -1.5001, -0.0001, -3, -0.0001, -0.0001, -1.5001, -1.5001, -0.0001, -1.5001, -1.5001, -0.0001, -3, -0.0001, -0.0001, -3, -0.0001, -0.0001, -1.5001, -3.0001, -0.0001, -1.5001, -1.5001, -0.0001, -0.0003, -3.0001, -0.0001, -0.0003, -3.0001, -0.0001, -1.5001, -1.5001, -0.0001, -1.5001, -1.5001, -0.0001, -0.0003, -3.0001, -0.0001, -3, -1.5001, -0.0001, -1.5001, -3.0001, -0.0001, -1.5001, -3.0001, -0.0001, -3, -1.5001, -0.0001, -3, -1.5001, -0.0001, -1.5001, -3.0001, -0.0001, -0.0003, -1.5001, -0.0001, 1.4996, -3.0001, -0.0001, 1.4996, -3.0001, -0.0001, -0.0003, -1.5001, -0.0001, -0.0003, -1.5001, -0.0001, 1.4996, -3.0001, -0.0001, 1.4996, -1.5001, -0.0001, 2.9995, -3.0001, -0.0001, 2.9995, -3.0001, -0.0001, 1.4996, -1.5001, -0.0001, 1.4996, -1.5001, -0.0001, 2.9995, -4.5002, -0.0001, -3, -3.0001, -0.0001, -1.5001, -4.5002, -0.0001, -1.5001, -4.5002, -0.0001, -3, -3.0001, -0.0001, -3, -3.0001, -0.0001, -1.5001, -4.5002, -0.0001, -1.5001, -3.0001, -0.0001, -0.0003, -4.5002, -0.0001, -0.0003, -4.5002, -0.0001, -1.5001, -3.0001, -0.0001, -1.5001, -3.0001, -0.0001, -0.0003, -4.5002, -0.0001, -0.0003, -3.0001, -0.0001, 1.4996, -4.5002, -0.0001, 1.4996, -4.5002, -0.0001, -0.0003, -3.0001, -0.0001, -0.0003, -3.0001, -0.0001, 1.4996, -4.5002, -0.0001, 1.4996, -3.0001, -0.0001, 2.9995, -4.5002, -0.0001, 2.9995, -4.5002, -0.0001, 1.4996, -3.0001, -0.0001, 1.4996, -3.0001, -0.0001, 2.9995, -4.5002, -0.0001, 2.9995, -3.0001, -0.0001, 4.4999, -4.5002, -0.0001, 4.4999, -4.5002, -0.0001, 2.9995, -3.0001, -0.0001, 2.9995, -3.0001, -0.0001, 4.4999, -3.0001, -0.0001, 2.9995, -1.5001, -0.0001, 4.4999, -3.0001, -0.0001, 4.4999, -3.0001, -0.0001, 2.9995, -1.5001, -0.0001, 2.9995, -1.5001, -0.0001, 4.4999, -1.5001, -0.0001, 2.9995, -0.0001, -0.0001, 4.4999, -1.5001, -0.0001, 4.4999, -1.5001, -0.0001, 2.9995, -0.0001, -0.0001, 2.9995, -0.0001, -0.0001, 4.4999, -0.0001, -0.0001, 2.9995, 1.4999, -0.0001, 4.4999, -0.0001, -0.0001, 4.4999, -0.0001, -0.0001, 2.9995, 1.4999, -0.0001, 2.9995, 1.4999, -0.0001, 4.4999, 1.4999, -0.0001, 2.9995, 3, -0.0001, 4.4999, 1.4999, -0.0001, 4.4999, 1.4999, -0.0001, 2.9995, 3, -0.0001, 2.9995, 3, -0.0001, 4.4999, 3, -0.0001, 2.9995, 4.5, -0.0001, 4.4999, 3, -0.0001, 4.4999, 3, -0.0001, 2.9995, 4.5, -0.0001, 2.9995, 4.5, -0.0001, 4.4999, 3, -0.0001, 1.4996, 4.5, -0.0001, 2.9995, 3, -0.0001, 2.9995, 3, -0.0001, 1.4996, 4.5, -0.0001, 1.4996, 4.5, -0.0001, 2.9995, 3, -0.0001, -0.0003, 4.5, -0.0001, 1.4996, 3, -0.0001, 1.4996, 3, -0.0001, -0.0003, 4.5, -0.0001, -0.0003, 4.5, -0.0001, 1.4996, 3, -0.0001, -1.5001, 4.5, -0.0001, -0.0003, 3, -0.0001, -0.0003, 3, -0.0001, -1.5001, 4.5, -0.0001, -1.5001, 4.5, -0.0001, -0.0003, 3, -0.0001, -3, 4.5, -0.0001, -1.5001, 3, -0.0001, -1.5001, 3, -0.0001, -3, 4.5, -0.0001, -3, 4.5, -0.0001, -1.5001, 3, -0.0001, -4.5005, 4.5, -0.0001, -3, 3, -0.0001, -3, 3, -0.0001, -4.5005, 4.5, -0.0001, -4.5005, 4.5, -0.0001, -3, 1.4999, -0.0001, -4.5005, 3, -0.0001, -3, 1.4999, -0.0001, -3, 1.4999, -0.0001, -4.5005, 3, -0.0001, -4.5005, 3, -0.0001, -3, -0.0001, -0.0001, -4.5005, 1.4999, -0.0001, -3, -0.0001, -0.0001, -3, -0.0001, -0.0001, -4.5005, 1.4999, -0.0001, -4.5005, 1.4999, -0.0001, -3, -1.5001, -0.0001, -4.5005, -0.0001, -0.0001, -3, -1.5001, -0.0001, -3, -1.5001, -0.0001, -4.5005, -0.0001, -0.0001, -4.5005, -0.0001, -0.0001, -3, -4.5002, -0.0001, -4.5005, -3Line truncated
[sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_uc5s3"]
data = PackedVector3Array(-1.5001, 0, 1.4999, -0.0001, 0, 2.9998, -1.5001, 0, 2.9998, -1.5001, 0, 1.4999, -0.0001, 0, 1.4999, -0.0001, 0, 2.9998, -1.5001, 0, -1.5, -0.0001, 0, -0.0001, -1.5001, 0, -0.0001, -1.5001, 0, -1.5, -0.0001, 0, -1.5, -0.0001, 0, -0.0001, -0.0001, 0, -1.5, 1.4998, 0, -0.0001, -0.0001, 0, -0.0001, -0.0001, 0, -1.5, 1.4998, 0, -1.5, 1.4998, 0, -0.0001, -0.0001, 0, -0.0001, 1.4998, 0, 1.4999, -0.0001, 0, 1.4999, -0.0001, 0, -0.0001, 1.4998, 0, -0.0001, 1.4998, 0, 1.4999, -0.0001, 0, 1.4999, 1.4998, 0, 2.9998, -0.0001, 0, 2.9998, -0.0001, 0, 1.4999, 1.4998, 0, 1.4999, 1.4998, 0, 2.9998, -1.5001, 0, -0.0001, -0.0001, 0, 1.4999, -1.5001, 0, 1.4999, -1.5001, 0, -0.0001, -0.0001, 0, -0.0001, -0.0001, 0, 1.4999, 1.4998, 0, 1.4999, 2.9998, 0, 2.9998, 1.4998, 0, 2.9998, 1.4998, 0, 1.4999, 2.9998, 0, 1.4999, 2.9998, 0, 2.9998, 1.4998, 0, -0.0001, 2.9998, 0, 1.4999, 1.4998, 0, 1.4999, 1.4998, 0, -0.0001, 2.9998, 0, -0.0001, 2.9998, 0, 1.4999, 1.4998, 0, -1.5, 2.9998, 0, -0.0001, 1.4998, 0, -0.0001, 1.4998, 0, -1.5, 2.9998, 0, -1.5, 2.9998, 0, -0.0001, 1.4998, 0, -3.0002, 2.9998, 0, -1.5, 1.4998, 0, -1.5, 1.4998, 0, -3.0002, 2.9998, 0, -3.0002, 2.9998, 0, -1.5, -0.0001, 0, -3.0002, 1.4998, 0, -1.5, -0.0001, 0, -1.5, -0.0001, 0, -3.0002, 1.4998, 0, -3.0002, 1.4998, 0, -1.5, -1.5001, 0, -3.0002, -0.0001, 0, -1.5, -1.5001, 0, -1.5, -1.5001, 0, -3.0002, -0.0001, 0, -3.0002, -0.0001, 0, -1.5, -3.0001, 0, -1.5, -1.5001, 0, -0.0001, -3.0001, 0, -0.0001, -3.0001, 0, -1.5, -1.5001, 0, -1.5, -1.5001, 0, -0.0001, -3.0001, 0, -3.0002, -1.5001, 0, -1.5, -3.0001, 0, -1.5, -3.0001, 0, -3.0002, -1.5001, 0, -3.0002, -1.5001, 0, -1.5, -3.0001, 0, -0.0001, -1.5001, 0, 1.4999, -3.0001, 0, 1.4999, -3.0001, 0, -0.0001, -1.5001, 0, -0.0001, -1.5001, 0, 1.4999, -3.0001, 0, 1.4999, -1.5001, 0, 2.9998, -3.0001, 0, 2.9998, -3.0001, 0, 1.4999, -1.5001, 0, 1.4999, -1.5001, 0, 2.9998, -4.5001, 0, -3.0002, -3.0001, 0, -1.5, -4.5001, 0, -1.5, -4.5001, 0, -3.0002, -3.0001, 0, -3.0002, -3.0001, 0, -1.5, -4.5001, 0, -1.5, -3.0001, 0, -0.0001, -4.5001, 0, -0.0001, -4.5001, 0, -1.5, -3.0001, 0, -1.5, -3.0001, 0, -0.0001, -4.5001, 0, -0.0001, -3.0001, 0, 1.4999, -4.5001, 0, 1.4999, -4.5001, 0, -0.0001, -3.0001, 0, -0.0001, -3.0001, 0, 1.4999, -4.5001, 0, 1.4999, -3.0001, 0, 2.9998, -4.5001, 0, 2.9998, -4.5001, 0, 1.4999, -3.0001, 0, 1.4999, -3.0001, 0, 2.9998, -4.5001, 0, 2.9998, -3.0001, 0, 4.5, -4.5001, 0, 4.5, -4.5001, 0, 2.9998, -3.0001, 0, 2.9998, -3.0001, 0, 4.5, -3.0001, 0, 2.9998, -1.5001, 0, 4.5, -3.0001, 0, 4.5, -3.0001, 0, 2.9998, -1.5001, 0, 2.9998, -1.5001, 0, 4.5, -1.5001, 0, 2.9998, -0.0001, 0, 4.5, -1.5001, 0, 4.5, -1.5001, 0, 2.9998, -0.0001, 0, 2.9998, -0.0001, 0, 4.5, -0.0001, 0, 2.9998, 1.4998, 0, 4.5, -0.0001, 0, 4.5, -0.0001, 0, 2.9998, 1.4998, 0, 2.9998, 1.4998, 0, 4.5, 1.4998, 0, 2.9998, 2.9998, 0, 4.5, 1.4998, 0, 4.5, 1.4998, 0, 2.9998, 2.9998, 0, 2.9998, 2.9998, 0, 4.5, 2.9998, 0, 2.9998, 4.4998, 0, 4.5, 2.9998, 0, 4.5, 2.9998, 0, 2.9998, 4.4998, 0, 2.9998, 4.4998, 0, 4.5, 2.9998, 0, 1.4999, 4.4998, 0, 2.9998, 2.9998, 0, 2.9998, 2.9998, 0, 1.4999, 4.4998, 0, 1.4999, 4.4998, 0, 2.9998, 2.9998, 0, -0.0001, 4.4998, 0, 1.4999, 2.9998, 0, 1.4999, 2.9998, 0, -0.0001, 4.4998, 0, -0.0001, 4.4998, 0, 1.4999, 2.9998, 0, -1.5, 4.4998, 0, -0.0001, 2.9998, 0, -0.0001, 2.9998, 0, -1.5, 4.4998, 0, -1.5, 4.4998, 0, -0.0001, 2.9998, 0, -3.0002, 4.4998, 0, -1.5, 2.9998, 0, -1.5, 2.9998, 0, -3.0002, 4.4998, 0, -3.0002, 4.4998, 0, -1.5, 2.9998, 0, -4.5001, 4.4998, 0, -3.0002, 2.9998, 0, -3.0002, 2.9998, 0, -4.5001, 4.4998, 0, -4.5001, 4.4998, 0, -3.0002, 1.4998, 0, -4.5001, 2.9998, 0, -3.0002, 1.4998, 0, -3.0002, 1.4998, 0, -4.5001, 2.9998, 0, -4.5001, 2.9998, 0, -3.0002, -0.0001, 0, -4.5001, 1.4998, 0, -3.0002, -0.0001, 0, -3.0002, -0.0001, 0, -4.5001, 1.4998, 0, -4.5001, 1.4998, 0, -3.0002, -1.5001, 0, -4.5001, -0.0001, 0, -3.0002, -1.5001, 0, -3.0002, -1.5001, 0, -4.5001, -0.0001, 0, -4.5001, -0.0001, 0, -3.0002, -4.5001, 0, -4.5001, -3.0001, 0, -3.0002, -4.5001, 0, -3.0002, -4.5001, 0, -4.5001, -3.0001, 0, -4.5001, -3.0001, 0, -3.0002, -3.0001, 0, -4.5001, -1.5001, 0, -3.0002, -3.0001, 0, -3.0002, -3.0001, 0, -4.5001, -1.5001, 0, -4.5001, -1.5001, 0, -3.0002, -0.0001, 0, -0.0001, -0.0001, 1.5, 1.4999, -0.0001, 0, 1.4999, -0.0001, 0, -0.0001, -0.0001, 1.5, -0.0001, -0.0001, 1.5, 1.4999, -0.0001, 0, -1.5, -0.0001, 1.5, -0.0001, -0.0001, 0, -0.0001, -0.0001, 0, -1.5, -0.0001, 1.5, -1.5, -0.0001, 1.5, -0.0001, -0.0001, 0, -3.0002, -0.0001, 1.5, -1.5, -0.0001, 0, -1.5, -0.0001, 0, -3.0002, -0.0001, 1.5, -3.0002, -0.0001, 1.5, -1.5, -0.0001, 0, 1.4999, -0.0001, 1.5, 2.9998, -0.0001, 0, 2.9998, -0.0001, 0, 1.4999, -0.0001, 1.5, 1.4999, -0.0001, 1.5, 2.9998, -0.0001, 0, 2.9998, -0.0001, 1.5, 4.5, -0.0001, 0, 4.5, -0.0001, 0, 2.9998, -0.0001, 1.5, 2.9998, -0.0001, 1.5, 4.5, -0.0001, 1.5, -3.0002, -0.0001, 3, -1.5, -0.0001, 1.5, -1.5, -0.0001, 1.5, -3.0002, -0.0001, 3, -3.0002, -0.0001, 3, -1.5, -0.0001, 1.5, -1.5, -0.0001, 3, -0.000Line truncated
[node name="test" instance=ExtResource("1_sb5ek")]
transform = Transform3D(20, 0, 0, 0, 20, 0, 0, 0, 20, 0, 0, 0)
[node name="Cube" parent="." index="0"]
surface_material_override/0 = SubResource("ShaderMaterial_fcflf")
@@ -21,4 +20,4 @@ surface_material_override/0 = SubResource("ShaderMaterial_fcflf")
[node name="StaticBody3D" type="StaticBody3D" parent="Cube" index="0"]
[node name="CollisionShape3D" type="CollisionShape3D" parent="Cube/StaticBody3D" index="0"]
shape = SubResource("ConcavePolygonShape3D_jxgrq")
shape = SubResource("ConcavePolygonShape3D_uc5s3")
+5 -6
View File
@@ -6,11 +6,10 @@
[ext_resource type="Texture2D" uid="uid://i34vweii6joy" path="res://textures/rosa.png" id="4_qdjyy"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_ls7r8"]
radius = 9.35148
height = 31.3716
radius = 0.331611
height = 0.804274
[sub_resource type="QuadMesh" id="QuadMesh_dyaax"]
size = Vector2(32, 32)
[sub_resource type="ShaderMaterial" id="ShaderMaterial_fegux"]
render_priority = 0
@@ -23,15 +22,15 @@ shader_parameter/npcTexture = ExtResource("4_qdjyy")
script = ExtResource("1_3g383")
[node name="Rosa Camera" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 0.130388, 0.991463, 0, -0.991463, 0.130388, 0, 30.9255, 0)
transform = Transform3D(1, 0, 0, 0, 0.130388, 0.991463, 0, -0.991463, 0.130388, 0, 3.14994, 0.404846)
fov = 30.0
script = ExtResource("2_tr66j")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 5.93694)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.126485)
shape = SubResource("CapsuleShape3D_ls7r8")
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 0.173648, 0.984808, 0, -0.984808, 0.173648, 0, 0, 0)
transform = Transform3D(1, 0, 0, 0, 0.173648, 0.984808, 0, -0.984808, 0.173648, 0.00989294, 0, 0)
mesh = SubResource("QuadMesh_dyaax")
surface_material_override/0 = SubResource("ShaderMaterial_fegux")
+10 -11
View File
@@ -4,14 +4,13 @@
[ext_resource type="Shader" path="res://shaders/NPC Shader.gdshader" id="1_xgcv1"]
[ext_resource type="Texture2D" uid="uid://i34vweii6joy" path="res://textures/rosa.png" id="2_shls4"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_32cew"]
radius = 9.35148
height = 31.3716
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_dw1sy"]
radius = 0.331611
height = 0.804274
[sub_resource type="QuadMesh" id="QuadMesh_evcrc"]
size = Vector2(32, 32)
[sub_resource type="QuadMesh" id="QuadMesh_xhkdv"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_mgbpu"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_l4utx"]
render_priority = 0
shader = ExtResource("1_xgcv1")
shader_parameter/frame = 0
@@ -22,10 +21,10 @@ shader_parameter/npcTexture = ExtResource("2_shls4")
script = ExtResource("1_61g2d")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 5.93694)
shape = SubResource("CapsuleShape3D_32cew")
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.126485)
shape = SubResource("CapsuleShape3D_dw1sy")
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 0.173648, 0.984808, 0, -0.984808, 0.173648, 0, 0, 0)
mesh = SubResource("QuadMesh_evcrc")
surface_material_override/0 = SubResource("ShaderMaterial_mgbpu")
transform = Transform3D(1, 0, 0, 0, 0.173648, 0.984808, 0, -0.984808, 0.173648, 0.00989294, 0, 0)
mesh = SubResource("QuadMesh_xhkdv")
surface_material_override/0 = SubResource("ShaderMaterial_l4utx")
+2 -2
View File
@@ -23,10 +23,10 @@ sky = SubResource("Sky_weucl")
environment = SubResource("Environment_18twt")
[node name="Rosa" parent="." instance=ExtResource("1_3u2u0")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -24.3489, 25.4112, -33.4617)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.651853, 0.684572, -0.0593004)
[node name="TestNpc" parent="." instance=ExtResource("2_6f3lj")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 15.919, 28.7961, 27.6146)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.545907, 0.459578, -0.399262)
[node name="OmniLight3D" type="OmniLight3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -38.1432, 54.7591, -25.7675)
+59 -7
View File
@@ -7,12 +7,14 @@ enum Direction {
EAST
}
var speed:float = 3200;
var friction:float = 7;
var gravity:float = 150;
var speed:float = 150;
var friction:float = 8.5;
var gravity:float = 30;
var direction = Direction.SOUTH;
var meshInstance:MeshInstance3D;
var underFootTile:int = -1;
var underFootPosition:Vector3;
func getDirectionVector() -> Vector3:
match direction:
@@ -33,9 +35,58 @@ func updateMovement(delta) -> void:
func updateOverworldLogic(delta) -> void:
pass
# Private methods
func _updateTileData() -> void:
# ray cast down
var offset = Vector3(0, 0, 0.426);
var query = PhysicsRayQueryParameters3D.create(
position + offset,
position + Vector3(0, -1, 0) + offset
)
query.collide_with_areas = true
query.exclude = [self]
var result = get_world_3d().direct_space_state.intersect_ray(query)
if !result or !result.collider:
return;
var collider = result.collider;
var colliderMesh = collider.get_node("../");
if !colliderMesh or !colliderMesh.mesh or colliderMesh.mesh.get_surface_count() == 0:
return;
# Get the face index (triangle)
var arrays = colliderMesh.mesh.surface_get_arrays(0);
var indiceIdx = result.face_index * 3;
# Get each indice of the triangle
var index0 = arrays[Mesh.ARRAY_INDEX][indiceIdx+0];
var index1 = arrays[Mesh.ARRAY_INDEX][indiceIdx+1];
var index2 = arrays[Mesh.ARRAY_INDEX][indiceIdx+2];
# Get each uv of each indice
var uv0:Vector2 = arrays[Mesh.ARRAY_TEX_UV][index0];
var uv1:Vector2 = arrays[Mesh.ARRAY_TEX_UV][index1];
var uv2:Vector2 = arrays[Mesh.ARRAY_TEX_UV][index2];
# Determine the lowest texture coordinate
var min = Vector2(min(uv0.x, uv1.x, uv2.x), min(uv0.y, uv1.y, uv2.y));
# Convert to column/row
var w = 768;
var h = w;
var tw = 48;
var th = tw;
var column = int(roundf(min.x * w)) / 48;
var row = int(roundf(min.y * h)) / 48;
var columns = 768 / 48;
underFootPosition = result.position;
underFootTile = column % columns + row * columns;
# Events
func _ready() -> void:
meshInstance = get_node("MeshInstance3D")
_updateTileData();
pass
func _process(delta:float) -> void:
@@ -46,16 +97,17 @@ func _process(delta:float) -> void:
var material:ShaderMaterial = meshInstance.get_surface_override_material(0)
material.set_shader_parameter("direction", direction)
func _physics_process(delta: float) -> void:
# Update movement
updateMovement(delta);
# Gravity and friction
if !is_on_floor():
velocity.y -= gravity * delta;
else:
velocity += -(velocity * friction * delta);
# Update movement
updateMovement(delta)
if velocity.length() != 0:
_updateTileData();
# Update character controller.
move_and_slide();
+3 -2
View File
@@ -1,6 +1,7 @@
extends Camera3D
var PIXEL_SCALE:float = 4.0;
const PIXEL_SCALE:float = 4.0;
const WORLD_UNITS:float = 32.0;
func _ready() -> void:
pass
@@ -10,7 +11,7 @@ func _process(delta: float) -> void:
var z:float = (
tan((deg_to_rad(180) - deg_to_rad(fov)) / 2.0) *
(get_viewport().size.y / 2.0)
) / PIXEL_SCALE;
) / PIXEL_SCALE / WORLD_UNITS;
var rosa = get_node("..");
var look = rosa.position;
+1 -1
View File
@@ -1,6 +1,6 @@
extends "res://scripts/OverworldEntity.gd"
var interactRange = 22;
var interactRange = 0.7;
func updateOverworldLogic(delta) -> void:
# Check if interact button is pressed
+1 -2
View File
@@ -4,11 +4,10 @@ render_mode cull_disabled;
uniform sampler2D tileset : filter_nearest;
void vertex() {
// Called for every vertex the material is visible on.
}
void fragment() {
vec4 textureColor = texture(tileset, UV);
vec4 textureColor = texture(tileset, UV) * COLOR;
if(textureColor.a == 0.0)
discard;
-19
View File
@@ -7,27 +7,8 @@ uniform int direction;
const int FRAMES = 3;
const int DIRECTIONS = 4;
//const bool BILLBOARD_ROTATION_LOCK = false;
void vertex() {
//if(BILLBOARD_ROTATION_LOCK) {
//mat4 modified_model_view = VIEW_MATRIX * mat4(
//INV_VIEW_MATRIX[0],
//INV_VIEW_MATRIX[1],
//INV_VIEW_MATRIX[2],
//MODEL_MATRIX[3]
//);
//MODELVIEW_MATRIX = modified_model_view;
//} else {
//mat4 modified_model_view = VIEW_MATRIX * mat4(
//INV_VIEW_MATRIX[0],
//MODEL_MATRIX[1],
//MODEL_MATRIX[2],
//MODEL_MATRIX[3]
//);
//MODELVIEW_MATRIX = modified_model_view;
//}
vec2 tileSize = vec2(1.0 / float(FRAMES), 1.0 / float(DIRECTIONS));
vec2 topLeft = tileSize * vec2(float(frame % FRAMES), float(direction % DIRECTIONS));
vec2 bottomRight = topLeft + tileSize;