From 6ca013fc6de3f1523100d9e4e043ead107b186cf Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 25 Nov 2023 18:55:12 +0100 Subject: [PATCH 1/4] torr --- torretta.tscn | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 torretta.tscn diff --git a/torretta.tscn b/torretta.tscn new file mode 100644 index 0000000..ba9054e --- /dev/null +++ b/torretta.tscn @@ -0,0 +1,19 @@ +[gd_scene load_steps=4 format=3 uid="uid://d0muettu1wwuw"] + +[ext_resource type="Script" path="res://Torretta.gd" id="1_vcetf"] +[ext_resource type="PackedScene" uid="uid://t0gblqb4yr8m" path="res://models/turret.glb" id="2_6xcje"] + +[sub_resource type="BoxShape3D" id="BoxShape3D_hwxik"] +size = Vector3(1.9188, 3.57475, 2.31203) + +[node name="Torretta" type="StaticBody3D"] +transform = Transform3D(-0.810819, 0, 0.585297, 0, 1, 0, -0.585297, 0, -0.810819, -11.1919, 0.928251, 6.08668) +script = ExtResource("1_vcetf") + +[node name="turret" parent="." instance=ExtResource("2_6xcje")] + +[node name="CollisionShape3D" type="CollisionShape3D" parent="."] +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="."] From 0793d1048550c9f108d407ab6cd3fb85f1aff12f Mon Sep 17 00:00:00 2001 From: Leonardo <321501@studenti.unimore.it> Date: Sat, 25 Nov 2023 19:03:33 +0100 Subject: [PATCH 2/4] Add vechi --- Root.tscn | 7 +++++-- panchina.tscn | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 panchina.tscn diff --git a/Root.tscn b/Root.tscn index 97c1c96..2215ffa 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=29 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"] @@ -12,11 +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" path="res://obstacles/dialog.tscn" id="10_6ihn6"] -[ext_resource type="PlaneMesh" 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="PackedScene" path="res://obstacles/goal_billboard.tscn" id="14_0ikhl"] [ext_resource type="Script" path="res://Torretta.gd" id="15_058li"] [ext_resource type="PackedScene" path="res://models/vent.tscn" id="15_hwvsi"] [ext_resource type="PackedScene" uid="uid://t0gblqb4yr8m" path="res://models/turret.glb" id="16_upw73"] +[ext_resource type="PackedScene" uid="uid://mahsivqsy3oo" path="res://panchina.tscn" id="18_ijdrl"] [sub_resource type="Theme" id="Theme_hkcet"] Label/fonts/font = ExtResource("3_p3wyc") @@ -257,4 +258,6 @@ shape = SubResource("BoxShape3D_hwxik") [node name="RayCast3D" type="RayCast3D" parent="Torretta"] +[node name="Panchina" parent="." instance=ExtResource("18_ijdrl")] + [connection signal="timeout" from="UI/TextBox/Timer" to="UI/TextBox" method="_on_timer_timeout"] diff --git a/panchina.tscn b/panchina.tscn new file mode 100644 index 0000000..268a2bb --- /dev/null +++ b/panchina.tscn @@ -0,0 +1,17 @@ +[gd_scene load_steps=3 format=3 uid="uid://mahsivqsy3oo"] + +[ext_resource type="PackedScene" uid="uid://ci3oqjm7d6n5c" path="res://models/veci.glb" id="1_5rsr2"] + +[sub_resource type="BoxShape3D" id="BoxShape3D_5q6jj"] +size = Vector3(6.47207, 3.91496, 2.44863) + +[node name="Panchina" type="StaticBody3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -11.9953, -1.41734, 0.942567) +collision_layer = 5 +collision_mask = 5 + +[node name="veci" parent="." instance=ExtResource("1_5rsr2")] + +[node name="CollisionShape3D" type="CollisionShape3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.91611, 2.53125, -0.454214) +shape = SubResource("BoxShape3D_5q6jj") From ef99b32bd3af76d02e99b8dbaa1837638cd7ad0c Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 25 Nov 2023 19:25:25 +0100 Subject: [PATCH 3/4] Fix bullet --- Root.tscn | 29 ++++++++---------------- Torretta.gd | 8 ++++--- obstacles/bullet.gd | 2 +- obstacles/bullet.tscn | 2 +- panchina.tscn => obstacles/panchina.tscn | 4 ++-- obstacles/torretta.tscn | 20 ++++++++++++++++ obstacles/torretta_ball.tscn | 19 ++++++++++++++++ torretta.tscn | 2 +- 8 files changed, 59 insertions(+), 27 deletions(-) rename panchina.tscn => obstacles/panchina.tscn (81%) create mode 100644 obstacles/torretta.tscn create mode 100644 obstacles/torretta_ball.tscn diff --git a/Root.tscn b/Root.tscn index 10ed0ec..d5142cc 100644 --- a/Root.tscn +++ b/Root.tscn @@ -12,13 +12,13 @@ [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://jy4q18wf2j41" uid="uid://jy4q18wf2j41" 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"] -[ext_resource type="PackedScene" uid="uid://mahsivqsy3oo" path="res://panchina.tscn" id="18_ijdrl"] +[ext_resource type="PackedScene" uid="uid://cbmkrd5kwiujt" path="res://obstacles/torretta.tscn" id="17_6hms3"] +[ext_resource type="PackedScene" uid="uid://mahsivqsy3oo" path="res://obstacles/panchina.tscn" id="18_ijdrl"] +[ext_resource type="PackedScene" uid="uid://c1p6udf66lht2" path="res://obstacles/bullet.tscn" id="19_fskgs"] [sub_resource type="Theme" id="Theme_hkcet"] Label/fonts/font = ExtResource("3_p3wyc") @@ -72,9 +72,6 @@ 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="."] @@ -260,18 +257,12 @@ 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"] - [node name="Panchina" parent="." instance=ExtResource("18_ijdrl")] +[node name="Torretta" parent="." instance=ExtResource("17_6hms3")] +transform = Transform3D(-0.810819, 0, 0.585297, 0, 1, 0, -0.585297, 0, -0.810819, -5.62694, 0, -13.6183) + +[node name="Bullet" parent="." instance=ExtResource("19_fskgs")] +transform = Transform3D(-4.37114e-08, 1, 4.37114e-08, 0, -4.37114e-08, 1, 1, 4.37114e-08, 1.91069e-15, -11.0235, 0, 14.2821) + [connection signal="timeout" from="UI/TextBox/Timer" to="UI/TextBox" method="_on_timer_timeout"] diff --git a/Torretta.gd b/Torretta.gd index dfcd042..f5b8468 100644 --- a/Torretta.gd +++ b/Torretta.gd @@ -5,7 +5,7 @@ extends StaticBody3D @export var max_distance: float = 30.0 @export var rotation_speed = 0.1 -@export var initial_cooldown: float = 0.1 +@export var initial_cooldown: float = 0.2 var bullet = preload("res://obstacles/bullet.tscn") var cooldown = 0 @@ -26,7 +26,6 @@ func _physics_process(delta): cooldown -= delta else: var bull = bullet.instantiate() - bull.global_position = global_position var diff_x = player.global_position.x - global_position.x var diff_z = player.global_position.z - global_position.z @@ -34,9 +33,12 @@ func _physics_process(delta): var diff = Vector3(diff_x, 0, diff_z) var norm = diff.normalized() + bull.position = global_position bull.set_linear_velocity(norm * 50) + bull.rotation.y = diff.signed_angle_to(Vector3.FORWARD, Vector3.DOWN) + + get_tree().root.find_child("Root", true, false).add_child(bull) - get_tree().root.add_child(bull) cooldown = initial_cooldown diff --git a/obstacles/bullet.gd b/obstacles/bullet.gd index b56b293..35fe709 100644 --- a/obstacles/bullet.gd +++ b/obstacles/bullet.gd @@ -14,4 +14,4 @@ func _process(delta): func _on_body_entered(body): if body is Player: body.velocity += (body.global_position - global_position).normalized() * 8 - queue_free() + queue_free() diff --git a/obstacles/bullet.tscn b/obstacles/bullet.tscn index 4148d1b..c96f998 100644 --- a/obstacles/bullet.tscn +++ b/obstacles/bullet.tscn @@ -9,7 +9,7 @@ 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 = 0 +collision_layer = 4 collision_mask = 4 gravity_scale = 0.0 continuous_cd = true diff --git a/panchina.tscn b/obstacles/panchina.tscn similarity index 81% rename from panchina.tscn rename to obstacles/panchina.tscn index 268a2bb..391787c 100644 --- a/panchina.tscn +++ b/obstacles/panchina.tscn @@ -3,7 +3,7 @@ [ext_resource type="PackedScene" uid="uid://ci3oqjm7d6n5c" path="res://models/veci.glb" id="1_5rsr2"] [sub_resource type="BoxShape3D" id="BoxShape3D_5q6jj"] -size = Vector3(6.47207, 3.91496, 2.44863) +size = Vector3(7.427, 3.83, 3.989) [node name="Panchina" type="StaticBody3D"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -11.9953, -1.41734, 0.942567) @@ -13,5 +13,5 @@ collision_mask = 5 [node name="veci" parent="." instance=ExtResource("1_5rsr2")] [node name="CollisionShape3D" type="CollisionShape3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.91611, 2.53125, -0.454214) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.54723, 2.53125, -0.928533) shape = SubResource("BoxShape3D_5q6jj") diff --git a/obstacles/torretta.tscn b/obstacles/torretta.tscn new file mode 100644 index 0000000..0824947 --- /dev/null +++ b/obstacles/torretta.tscn @@ -0,0 +1,20 @@ +[gd_scene load_steps=4 format=3 uid="uid://cbmkrd5kwiujt"] + +[ext_resource type="Script" path="res://Torretta.gd" id="1_wqejx"] +[ext_resource type="PackedScene" uid="uid://t0gblqb4yr8m" path="res://models/turret.glb" id="2_m7e8h"] + +[sub_resource type="BoxShape3D" id="BoxShape3D_hwxik"] +size = Vector3(1.9188, 3.57475, 2.31203) + +[node name="Torretta" type="StaticBody3D"] +transform = Transform3D(-0.810819, 0, 0.585297, 0, 1, 0, -0.585297, 0, -0.810819, -11.1919, 0.928251, 6.08668) +script = ExtResource("1_wqejx") +initial_cooldown = 0.5 + +[node name="turret" parent="." instance=ExtResource("2_m7e8h")] + +[node name="CollisionShape3D" type="CollisionShape3D" parent="."] +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="."] diff --git a/obstacles/torretta_ball.tscn b/obstacles/torretta_ball.tscn new file mode 100644 index 0000000..0849ac5 --- /dev/null +++ b/obstacles/torretta_ball.tscn @@ -0,0 +1,19 @@ +[gd_scene load_steps=4 format=3 uid="uid://ds01yl3tf0tva"] + +[ext_resource type="Script" path="res://Torretta.gd" id="1_6tulh"] +[ext_resource type="PackedScene" uid="uid://t0gblqb4yr8m" path="res://models/turret.glb" id="2_64e5x"] + +[sub_resource type="BoxShape3D" id="BoxShape3D_hwxik"] +size = Vector3(1.9188, 3.57475, 2.31203) + +[node name="Torretta" type="StaticBody3D"] +transform = Transform3D(-0.810819, 0, 0.585297, 0, 1, 0, -0.585297, 0, -0.810819, -11.1919, 0.928251, 6.08668) +script = ExtResource("1_6tulh") + +[node name="turret" parent="." instance=ExtResource("2_64e5x")] + +[node name="CollisionShape3D" type="CollisionShape3D" parent="."] +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="."] diff --git a/torretta.tscn b/torretta.tscn index ba9054e..f207cdd 100644 --- a/torretta.tscn +++ b/torretta.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=4 format=3 uid="uid://d0muettu1wwuw"] +[gd_scene load_steps=4 format=3 uid="uid://lnbogqv7l2q4"] [ext_resource type="Script" path="res://Torretta.gd" id="1_vcetf"] [ext_resource type="PackedScene" uid="uid://t0gblqb4yr8m" path="res://models/turret.glb" id="2_6xcje"] From 3ba4b54c45f1602f539d0a8513e07d31851124cb Mon Sep 17 00:00:00 2001 From: Leonardo <321501@studenti.unimore.it> Date: Sat, 25 Nov 2023 19:39:22 +0100 Subject: [PATCH 4/4] edit bullet model --- Root.tscn | 8 ++++---- obstacles/bullet.tscn | 12 +++++------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Root.tscn b/Root.tscn index d5142cc..bf60af3 100644 --- a/Root.tscn +++ b/Root.tscn @@ -1,7 +1,7 @@ [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"] +[ext_resource type="Material" path="res://Unshaded.material" id="2_upp15"] [ext_resource type="Texture2D" uid="uid://uogmi4pvp64t" path="res://addons/bisio.png" id="3_27tel"] [ext_resource type="FontFile" uid="uid://cseshyj4yw2f5" path="res://fonts/FiraSans-Medium.ttf" id="3_p3wyc"] [ext_resource type="Script" path="res://GameTimer.gd" id="3_y362g"] @@ -11,11 +11,11 @@ [ext_resource type="Script" path="res://Camera3D.gd" id="8_auifr"] [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="PackedScene" path="res://obstacles/dialog.tscn" id="10_6ihn6"] [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="PackedScene" uid="uid://crbal5m8uhcd5" path="res://obstacles/vent.tscn" id="15_hwvsi"] +[ext_resource type="PackedScene" path="res://obstacles/goal_billboard.tscn" id="14_0ikhl"] +[ext_resource type="PackedScene" path="res://obstacles/vent.tscn" id="15_hwvsi"] [ext_resource type="PackedScene" uid="uid://cbmkrd5kwiujt" path="res://obstacles/torretta.tscn" id="17_6hms3"] [ext_resource type="PackedScene" uid="uid://mahsivqsy3oo" path="res://obstacles/panchina.tscn" id="18_ijdrl"] [ext_resource type="PackedScene" uid="uid://c1p6udf66lht2" path="res://obstacles/bullet.tscn" id="19_fskgs"] diff --git a/obstacles/bullet.tscn b/obstacles/bullet.tscn index c96f998..87c94fb 100644 --- a/obstacles/bullet.tscn +++ b/obstacles/bullet.tscn @@ -1,8 +1,7 @@ [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"] +[ext_resource type="PackedScene" uid="uid://cis3y8bj1x60j" path="res://models/can.glb" id="2_jdw1w"] [sub_resource type="CylinderShape3D" id="CylinderShape3D_rk7k5"] radius = 0.58729 @@ -17,12 +16,11 @@ max_contacts_reported = 1 contact_monitor = true 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) +transform = Transform3D(0.488, 0, 2.90929e-22, 0, 0.331, 0, -2.90929e-22, 0, 0.488, 0, 0, 0) shape = SubResource("CylinderShape3D_rk7k5") +[node name="can" parent="." instance=ExtResource("2_jdw1w")] +transform = Transform3D(0.267232, 8.88178e-16, -5.29396e-23, -8.88178e-16, 0.267232, 8.88178e-16, -2.11758e-22, -8.88178e-16, 0.267232, 0, 0, 0) + [connection signal="body_entered" from="." to="." method="_on_body_entered"]