diff --git a/Root.tscn b/Root.tscn index 09d5a6d..2c05df4 100644 --- a/Root.tscn +++ b/Root.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=28 format=3 uid="uid://4whij2hmts0t"] +[gd_scene load_steps=31 format=3 uid="uid://4whij2hmts0t"] [ext_resource type="Script" path="res://Player.gd" id="1_wt4gx"] [ext_resource type="Material" uid="uid://dondfiavgo2ws" path="res://Unshaded.material" id="2_upp15"] @@ -12,10 +12,12 @@ [ext_resource type="Texture2D" uid="uid://ct6sngef76p35" path="res://addons/grass.png" id="9_i8cb1"] [ext_resource type="PackedScene" uid="uid://bxj354o6rycsf" path="res://obstacles/house_c.tscn" id="9_xyam4"] [ext_resource type="PackedScene" uid="uid://ccs202pcy4pce" path="res://obstacles/dialog.tscn" id="10_6ihn6"] -[ext_resource type="PlaneMesh" uid="uid://b2jhvncq5j8pe" path="res://road_mesh_something.tres" id="10_7jwjs"] +[ext_resource type="PlaneMesh" uid="uid://jy4q18wf2j41" path="res://road_mesh_something.tres" id="10_7jwjs"] [ext_resource type="Texture2D" uid="uid://bx05lcriqc602" path="res://addons/asphalt_blank.png" id="11_kxmgb"] [ext_resource type="PackedScene" uid="uid://d3ikq1a6muafo" path="res://obstacles/goal_billboard.tscn" id="14_0ikhl"] +[ext_resource type="Script" path="res://Torretta.gd" id="15_058li"] [ext_resource type="PackedScene" uid="uid://crbal5m8uhcd5" path="res://obstacles/vent.tscn" id="15_hwvsi"] +[ext_resource type="PackedScene" uid="uid://t0gblqb4yr8m" path="res://models/turret.glb" id="16_upw73"] [sub_resource type="Theme" id="Theme_hkcet"] Label/fonts/font = ExtResource("3_p3wyc") @@ -69,6 +71,9 @@ item/3/shapes = [] item/3/navigation_mesh_transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0) item/3/navigation_layers = 1 +[sub_resource type="BoxShape3D" id="BoxShape3D_hwxik"] +size = Vector3(1.9188, 3.57475, 2.31203) + [node name="Root" type="Node3D"] [node name="UI" type="Control" parent="."] @@ -158,6 +163,7 @@ script = ExtResource("3_y362g") [node name="Player" type="CharacterBody3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.927202, 0) +collision_layer = 5 script = ExtResource("1_wt4gx") input_accel = 8.0 jump_impulse = Vector3(0, 10, 0) @@ -190,6 +196,8 @@ mesh = SubResource("BoxMesh_4tnse") skeleton = NodePath("../..") [node name="Plane" type="StaticBody3D" parent="."] +collision_layer = 5 +collision_mask = 5 [node name="CollisionShape3D" type="CollisionShape3D" parent="Plane"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -2, 0) @@ -217,15 +225,19 @@ shadow_enabled = true [node name="HouseC" parent="." instance=ExtResource("9_xyam4")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 14.9482, 0, -6.46428) +collision_layer = 5 [node name="HouseC2" parent="." instance=ExtResource("9_xyam4")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 7.94815, 0, 15.5357) +collision_layer = 5 [node name="HouseC3" parent="." instance=ExtResource("9_xyam4")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -21.0518, 0, -18.4643) +collision_layer = 5 [node name="HouseC4" parent="." instance=ExtResource("9_xyam4")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -18.0518, 0, 8.53572) +collision_layer = 5 [node name="Dialog" parent="." instance=ExtResource("10_6ihn6")] transform = Transform3D(4, 0, 0, 0, 4, 0, 0, 0, 4, 0, 1, -7) @@ -247,4 +259,16 @@ duration = 1.0 [node name="Vent" parent="." instance=ExtResource("15_hwvsi")] transform = Transform3D(4, 0, 0, 0, 4, 0, 0, 0, 4, -2.89718, 0, 8.66797) +[node name="Torretta" type="StaticBody3D" parent="."] +transform = Transform3D(-0.810819, 0, 0.585297, 0, 1, 0, -0.585297, 0, -0.810819, -11.1919, 0.928251, 6.08668) +script = ExtResource("15_058li") + +[node name="turret" parent="Torretta" instance=ExtResource("16_upw73")] + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Torretta"] +transform = Transform3D(1, 0, -2.98023e-08, 0, 1, 0, 2.98023e-08, 0, 1, 0, 1.09828, 0) +shape = SubResource("BoxShape3D_hwxik") + +[node name="RayCast3D" type="RayCast3D" parent="Torretta"] + [connection signal="timeout" from="UI/TextBox/Timer" to="UI/TextBox" method="_on_timer_timeout"] diff --git a/Torretta.gd b/Torretta.gd new file mode 100644 index 0000000..28f2283 --- /dev/null +++ b/Torretta.gd @@ -0,0 +1,36 @@ +extends StaticBody3D + +@onready var player: Player = get_tree().root.find_children("Player", "Player", true, false)[0] + + +@export var max_distance: float = 30.0 +@export var rotation_speed = 0.1 + +var bullet = preload("res://obstacles/bullet.tscn") +var cooldown = 0 + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +func _physics_process(delta): + var distance = player.global_position.distance_to(global_position) + if distance > max_distance: + return + + rotation.y = (global_position - player.global_position).signed_angle_to(Vector3.FORWARD, Vector3.DOWN) + PI/2 + + if cooldown > 0: + cooldown -= delta + else: + var bull = bullet.instantiate() + bull.global_position = global_position + bull.set_linear_velocity((player.global_position - global_position).normalized() * 50) + + get_tree().root.add_child(bull) + cooldown = 5 + + + + diff --git a/addons/asphalt.png.import b/addons/asphalt.png.import index b486444..00e8525 100644 --- a/addons/asphalt.png.import +++ b/addons/asphalt.png.import @@ -2,7 +2,7 @@ importer="texture" type="CompressedTexture2D" -uid="uid://2cuubqxj75u6" +uid="uid://cpbb24lnr0sf4" path.s3tc="res://.godot/imported/asphalt.png-3e65ac69213480c761c57143e40284dd.s3tc.ctex" metadata={ "imported_formats": ["s3tc_bptc"], diff --git a/addons/goal.png.import b/addons/goal.png.import index dbe0c06..96a7b50 100644 --- a/addons/goal.png.import +++ b/addons/goal.png.import @@ -2,7 +2,7 @@ importer="texture" type="CompressedTexture2D" -uid="uid://d0hvok3thbj6l" +uid="uid://gqkaflqatol1" path.s3tc="res://.godot/imported/goal.png-9eb3689ba6826748bdd2bb9a752c7f05.s3tc.ctex" metadata={ "imported_formats": ["s3tc_bptc"], diff --git a/bullet.gd b/bullet.gd new file mode 100644 index 0000000..92626b9 --- /dev/null +++ b/bullet.gd @@ -0,0 +1,11 @@ +extends Node3D + + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass diff --git a/obstacles/bullet.gd b/obstacles/bullet.gd new file mode 100644 index 0000000..a9380e1 --- /dev/null +++ b/obstacles/bullet.gd @@ -0,0 +1,18 @@ +extends Node3D + + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass + + +func _on_body_entered(body): + if body is Player: + body.velocity += (global_position - body.global_position).normalized() * 5 + print("AAAAAA") + queue_free() diff --git a/obstacles/bullet.tscn b/obstacles/bullet.tscn new file mode 100644 index 0000000..dc49d54 --- /dev/null +++ b/obstacles/bullet.tscn @@ -0,0 +1,24 @@ +[gd_scene load_steps=4 format=3 uid="uid://c1p6udf66lht2"] + +[ext_resource type="Script" path="res://obstacles/bullet.gd" id="1_dawle"] + +[sub_resource type="CylinderMesh" id="CylinderMesh_nnt0g"] + +[sub_resource type="CylinderShape3D" id="CylinderShape3D_rk7k5"] +radius = 0.58729 + +[node name="Bullet" type="RigidBody3D"] +transform = Transform3D(-4.37114e-08, 1, 4.37114e-08, 0, -4.37114e-08, 1, 1, 4.37114e-08, 1.91069e-15, 0, 0, 0) +collision_layer = 4 +collision_mask = 4 +script = ExtResource("1_dawle") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="."] +transform = Transform3D(0.4, 0, 0, 0, 0.4, 0, 0, 0, 0.4, 0, 0, 0) +mesh = SubResource("CylinderMesh_nnt0g") + +[node name="CollisionShape3D" type="CollisionShape3D" parent="."] +transform = Transform3D(0.4, 0, 0, 0, 0.4, -3.34074e-23, 0, 3.34074e-23, 0.4, 0, 0, 0) +shape = SubResource("CylinderShape3D_rk7k5") + +[connection signal="body_entered" from="." to="." method="_on_body_entered"] diff --git a/road_mesh_something.tres b/road_mesh_something.tres index 5238ac7..1b095a6 100644 --- a/road_mesh_something.tres +++ b/road_mesh_something.tres @@ -1,6 +1,6 @@ -[gd_resource type="PlaneMesh" load_steps=3 format=3 uid="uid://b2jhvncq5j8pe"] +[gd_resource type="PlaneMesh" load_steps=3 format=3 uid="uid://jy4q18wf2j41"] -[ext_resource type="Texture2D" uid="uid://2cuubqxj75u6" path="res://addons/asphalt.png" id="1_6yda2"] +[ext_resource type="Texture2D" uid="uid://cpbb24lnr0sf4" path="res://addons/asphalt.png" id="1_6yda2"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_vlayp"] albedo_texture = ExtResource("1_6yda2")