diff --git a/Tiles/TileTurn.gd b/Tiles/TileTurn.gd index 7873bb4..4847512 100644 --- a/Tiles/TileTurn.gd +++ b/Tiles/TileTurn.gd @@ -31,16 +31,6 @@ func turn(direction): paths[path_index+1] = get_path_by_direction(current_direction) -#func has_next_path() -> bool: - #return on_main_path - - -#func get_next_path() -> Path3D: - #if not on_main_path: - #return get_path_by_direction(current_direction) - #return null - - func get_path_by_direction(direction) -> Path3D: if direction == "forward" and path_forward != null: return path_forward diff --git a/Tiles/TileTurn1.tscn b/Tiles/TileTurn1.tscn index fe98e73..5f1dbbd 100644 --- a/Tiles/TileTurn1.tscn +++ b/Tiles/TileTurn1.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=10 format=3 uid="uid://b88nuwe42bhc1"] +[gd_scene load_steps=11 format=3 uid="uid://b88nuwe42bhc1"] [ext_resource type="Script" path="res://Tiles/TileTurn.gd" id="1_wj6en"] +[ext_resource type="PackedScene" uid="uid://dkcjoccsgbggg" path="res://obstacles/obstacle.tscn" id="2_tnkvo"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_cwetn"] cull_mode = 2 @@ -22,7 +23,7 @@ point_count = 2 [sub_resource type="Curve3D" id="Curve3D_5ouye"] _data = { -"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, -5), +"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, -6), "tilts": PackedFloat32Array(0, 0) } point_count = 2 @@ -104,3 +105,6 @@ tilt_enabled = false [node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0194125, 2.2431, 4.34685) shape = SubResource("BoxShape3D_uvh3q") + +[node name="Obstacle" parent="." instance=ExtResource("2_tnkvo")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -5.14771) diff --git a/character/character.gd b/character/character.gd index db4df0d..899c703 100644 --- a/character/character.gd +++ b/character/character.gd @@ -31,3 +31,14 @@ func _process(delta: float): var travel: float = speed * delta tile.follow.progress += travel total_distance += travel + + +func _on_area_entered(area): + if area is Obstacle: + handle_obstacle(area) + + +func handle_obstacle(obstacle: Obstacle): + if obstacle.effect == Obstacle.ObstacleEffect.Kill: + print("kill") + speed = 0 diff --git a/character/character.tscn b/character/character.tscn index 82900c2..e1eb571 100644 --- a/character/character.tscn +++ b/character/character.tscn @@ -20,3 +20,5 @@ skeleton = NodePath("") [node name="Camera3D" type="Camera3D" parent="."] transform = Transform3D(1, -4.52535e-08, 1.68888e-07, -1.77636e-15, 0.965926, 0.258819, -1.74846e-07, -0.258819, 0.965926, 0, 2, 2.558) + +[connection signal="area_entered" from="." to="." method="_on_area_entered"] diff --git a/obstacles/obstacle.gd b/obstacles/obstacle.gd new file mode 100644 index 0000000..3355978 --- /dev/null +++ b/obstacles/obstacle.gd @@ -0,0 +1,16 @@ +extends Area3D +class_name Obstacle + +@export var effect: ObstacleEffect + +enum ObstacleEffect { + Kill, + Trip, +} + +func _ready(): + pass + + +func _process(delta): + pass diff --git a/obstacles/obstacle.tscn b/obstacles/obstacle.tscn new file mode 100644 index 0000000..9eaf5ff --- /dev/null +++ b/obstacles/obstacle.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=3 format=3 uid="uid://dkcjoccsgbggg"] + +[ext_resource type="Script" path="res://obstacles/obstacle.gd" id="1_ab8so"] + +[sub_resource type="BoxShape3D" id="BoxShape3D_c6wik"] +size = Vector3(10, 2, 0.5) + +[node name="Obstacle" type="Area3D"] +script = ExtResource("1_ab8so") + +[node name="CollisionShape3D" type="CollisionShape3D" parent="."] +shape = SubResource("BoxShape3D_c6wik")