From 40add5cda50da2cffcd9f33f38888677f19c91e4 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 3 Apr 2022 02:56:09 +0200 Subject: [PATCH] :wrench: Make `BulletSpawn` a simple `Node` --- src/entities/Player.tscn | 5 ++--- src/entities/behaviours/BulletSpawn.gd | 4 ++-- src/entities/behaviours/BulletSpawn.tscn | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/entities/Player.tscn b/src/entities/Player.tscn index b80c31e..9074351 100644 --- a/src/entities/Player.tscn +++ b/src/entities/Player.tscn @@ -2,7 +2,7 @@ [ext_resource path="res://src/mechanics/White.png" type="Texture" id=1] [ext_resource path="res://src/entities/behaviours/PlayerMovement.tscn" type="PackedScene" id=2] -[ext_resource path="res://src/entities/behaviours/BulletSpawn.gd" type="Script" id=3] +[ext_resource path="res://src/entities/behaviours/BulletSpawn.tscn" type="PackedScene" id=3] [sub_resource type="RectangleShape2D" id=1] extents = Vector2( 16, 16 ) @@ -17,5 +17,4 @@ texture = ExtResource( 1 ) [node name="Shape" type="CollisionShape2D" parent="."] shape = SubResource( 1 ) -[node name="BulletSpawner" type="Node2D" parent="."] -script = ExtResource( 3 ) +[node name="BulletSpawn" parent="." instance=ExtResource( 3 )] diff --git a/src/entities/behaviours/BulletSpawn.gd b/src/entities/behaviours/BulletSpawn.gd index cb9569e..b7a07f5 100644 --- a/src/entities/behaviours/BulletSpawn.gd +++ b/src/entities/behaviours/BulletSpawn.gd @@ -1,4 +1,4 @@ -extends Node2D +extends Node export var bullet: PackedScene = preload("res://src/entities/Bullet.tscn") @@ -16,5 +16,5 @@ func shoot(): var new_bullet = bullet.instance() new_bullet.set_position(source.global_position) bullet_container_node.add_child(new_bullet) - var rotation = new_bullet.get_angle_to(get_global_mouse_position()) + var rotation = new_bullet.get_angle_to(source.get_global_mouse_position()) new_bullet.set_rotation(rotation) diff --git a/src/entities/behaviours/BulletSpawn.tscn b/src/entities/behaviours/BulletSpawn.tscn index 85f3a5f..db25fb2 100644 --- a/src/entities/behaviours/BulletSpawn.tscn +++ b/src/entities/behaviours/BulletSpawn.tscn @@ -2,5 +2,5 @@ [ext_resource path="res://src/entities/behaviours/BulletSpawn.gd" type="Script" id=1] -[node name="BulletSpawn" type="Node2D"] +[node name="BulletSpawn" type="Node"] script = ExtResource( 1 )