From ee9a2e9562a32240328d91749086908a51a65251 Mon Sep 17 00:00:00 2001 From: Leonardo <321501@studenti.unimore.it> Date: Sat, 25 Nov 2023 18:31:47 +0100 Subject: [PATCH 1/2] Add bullet --- Root.tscn | 28 ++++++++++++++++++++++++++-- Torretta.gd | 36 ++++++++++++++++++++++++++++++++++++ bullet.gd | 11 +++++++++++ obstacles/bullet.gd | 18 ++++++++++++++++++ obstacles/bullet.tscn | 24 ++++++++++++++++++++++++ 5 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 Torretta.gd create mode 100644 bullet.gd create mode 100644 obstacles/bullet.gd create mode 100644 obstacles/bullet.tscn diff --git a/Root.tscn b/Root.tscn index 1d0f49c..0d08ced 100644 --- a/Root.tscn +++ b/Root.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=24 format=3 uid="uid://4whij2hmts0t"] +[gd_scene load_steps=27 format=3 uid="uid://4whij2hmts0t"] [ext_resource type="Script" path="res://Player.gd" id="1_wt4gx"] [ext_resource type="Material" path="res://Unshaded.material" id="2_upp15"] @@ -10,10 +10,12 @@ [ext_resource type="FontFile" uid="uid://qf3uxmta6lpw" path="res://fonts/FiraCode-Medium.ttf" id="5_yvnu2"] [ext_resource type="PackedScene" uid="uid://4i2c481rpxe3" path="res://models/cinno.glb" id="8_32hx2"] [ext_resource type="Script" path="res://Camera3D.gd" id="8_auifr"] -[ext_resource type="PackedScene" path="res://obstacles/house_c.tscn" id="9_xyam4"] +[ext_resource type="PackedScene" uid="uid://bxj354o6rycsf" path="res://obstacles/house_c.tscn" id="9_xyam4"] [ext_resource type="PackedScene" path="res://obstacles/dialog.tscn" id="10_6ihn6"] [ext_resource type="Script" path="res://Buccia.gd" id="12_7dfpx"] [ext_resource type="PackedScene" uid="uid://72q4p7x8l08y" path="res://models/banana.glb" id="13_ecp45"] +[ext_resource type="Script" path="res://Torretta.gd" id="15_058li"] +[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") @@ -45,6 +47,9 @@ size = Vector3(200, 4, 200) [sub_resource type="BoxShape3D" id="BoxShape3D_p1ebg"] size = Vector3(1.5, 1.5, 1.5) +[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="."] @@ -134,6 +139,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) @@ -166,6 +172,8 @@ mesh = SubResource("BoxMesh_4tnse") skeleton = NodePath("../..") [node name="Plane" type="StaticBody3D" parent="."] +collision_layer = 5 +collision_mask = 5 [node name="MeshInstance3D" type="MeshInstance3D" parent="Plane"] mesh = SubResource("PlaneMesh_opk07") @@ -187,15 +195,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) @@ -252,6 +264,18 @@ script = ExtResource("12_7dfpx") transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.75, 0) shape = SubResource("BoxShape3D_p1ebg") +[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"] [connection signal="body_entered" from="Buccia" to="Buccia" method="_on_body_entered"] [connection signal="body_entered" from="Buccia2" to="Buccia2" method="_on_body_entered"] 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/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"] From dc329b9b49d2579edab93608f4997de6d07522c2 Mon Sep 17 00:00:00 2001 From: Leonardo <321501@studenti.unimore.it> Date: Sat, 25 Nov 2023 18:35:10 +0100 Subject: [PATCH 2/2] Zcfadsfdsf --- addons/asphalt.png.import | 35 +++++++++++++++++++++++++++++++++++ addons/goal.png.import | 35 +++++++++++++++++++++++++++++++++++ road_mesh_something.tres | 4 ++-- 3 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 addons/asphalt.png.import create mode 100644 addons/goal.png.import diff --git a/addons/asphalt.png.import b/addons/asphalt.png.import new file mode 100644 index 0000000..00e8525 --- /dev/null +++ b/addons/asphalt.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cpbb24lnr0sf4" +path.s3tc="res://.godot/imported/asphalt.png-3e65ac69213480c761c57143e40284dd.s3tc.ctex" +metadata={ +"imported_formats": ["s3tc_bptc"], +"vram_texture": true +} + +[deps] + +source_file="res://addons/asphalt.png" +dest_files=["res://.godot/imported/asphalt.png-3e65ac69213480c761c57143e40284dd.s3tc.ctex"] + +[params] + +compress/mode=2 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=true +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=0 diff --git a/addons/goal.png.import b/addons/goal.png.import new file mode 100644 index 0000000..96a7b50 --- /dev/null +++ b/addons/goal.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://gqkaflqatol1" +path.s3tc="res://.godot/imported/goal.png-9eb3689ba6826748bdd2bb9a752c7f05.s3tc.ctex" +metadata={ +"imported_formats": ["s3tc_bptc"], +"vram_texture": true +} + +[deps] + +source_file="res://addons/goal.png" +dest_files=["res://.godot/imported/goal.png-9eb3689ba6826748bdd2bb9a752c7f05.s3tc.ctex"] + +[params] + +compress/mode=2 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=true +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=0 diff --git a/road_mesh_something.tres b/road_mesh_something.tres index 39aaa47..2722657 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_30fli"] albedo_texture = ExtResource("1_6yda2")