From ab27c3f440e51d51034b15cedd4b2dc49c8df289 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 25 Nov 2023 18:49:48 +0100 Subject: [PATCH] asdiogrdiogeriog --- Torretta.gd | 12 ++++++++++-- bullet.gd | 11 ----------- obstacles/bullet.gd | 3 +-- obstacles/bullet.tscn | 6 +++++- 4 files changed, 16 insertions(+), 16 deletions(-) delete mode 100644 bullet.gd diff --git a/Torretta.gd b/Torretta.gd index 28f2283..dfcd042 100644 --- a/Torretta.gd +++ b/Torretta.gd @@ -5,6 +5,7 @@ extends StaticBody3D @export var max_distance: float = 30.0 @export var rotation_speed = 0.1 +@export var initial_cooldown: float = 0.1 var bullet = preload("res://obstacles/bullet.tscn") var cooldown = 0 @@ -26,10 +27,17 @@ func _physics_process(delta): else: var bull = bullet.instantiate() bull.global_position = global_position - bull.set_linear_velocity((player.global_position - global_position).normalized() * 50) + + var diff_x = player.global_position.x - global_position.x + var diff_z = player.global_position.z - global_position.z + + var diff = Vector3(diff_x, 0, diff_z) + var norm = diff.normalized() + + bull.set_linear_velocity(norm * 50) get_tree().root.add_child(bull) - cooldown = 5 + cooldown = initial_cooldown diff --git a/bullet.gd b/bullet.gd deleted file mode 100644 index 92626b9..0000000 --- a/bullet.gd +++ /dev/null @@ -1,11 +0,0 @@ -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 index a9380e1..b56b293 100644 --- a/obstacles/bullet.gd +++ b/obstacles/bullet.gd @@ -13,6 +13,5 @@ func _process(delta): func _on_body_entered(body): if body is Player: - body.velocity += (global_position - body.global_position).normalized() * 5 - print("AAAAAA") + body.velocity += (body.global_position - global_position).normalized() * 8 queue_free() diff --git a/obstacles/bullet.tscn b/obstacles/bullet.tscn index dc49d54..4148d1b 100644 --- a/obstacles/bullet.tscn +++ b/obstacles/bullet.tscn @@ -9,8 +9,12 @@ 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_layer = 0 collision_mask = 4 +gravity_scale = 0.0 +continuous_cd = true +max_contacts_reported = 1 +contact_monitor = true script = ExtResource("1_dawle") [node name="MeshInstance3D" type="MeshInstance3D" parent="."]