diff --git a/src/entities/Bullet.tscn b/src/entities/Bullet.tscn index 25c31ce..d47abfa 100644 --- a/src/entities/Bullet.tscn +++ b/src/entities/Bullet.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=5 format=2] [ext_resource path="res://src/mechanics/White.png" type="Texture" id=1] [ext_resource path="res://src/entities/behaviours/BulletMovement.gd" type="Script" id=2] +[ext_resource path="res://src/entities/behaviours/Ownership.tscn" type="PackedScene" id=3] [sub_resource type="RectangleShape2D" id=1] extents = Vector2( 16, 8 ) @@ -19,3 +20,5 @@ texture = ExtResource( 1 ) [node name="BulletMovement" type="Node" parent="."] script = ExtResource( 2 ) + +[node name="Ownership" parent="." instance=ExtResource( 3 )] diff --git a/src/entities/behaviours/BulletSpawn.gd b/src/entities/behaviours/BulletSpawn.gd index b7a07f5..02a7c9d 100644 --- a/src/entities/behaviours/BulletSpawn.gd +++ b/src/entities/behaviours/BulletSpawn.gd @@ -18,3 +18,4 @@ func shoot(): bullet_container_node.add_child(new_bullet) var rotation = new_bullet.get_angle_to(source.get_global_mouse_position()) new_bullet.set_rotation(rotation) + new_bullet.get_node("Ownership").entity_owner = source diff --git a/src/entities/behaviours/Ownership.tscn b/src/entities/behaviours/Ownership.tscn index a0f8b10..a2468df 100644 --- a/src/entities/behaviours/Ownership.tscn +++ b/src/entities/behaviours/Ownership.tscn @@ -1,3 +1,6 @@ -[gd_scene format=2] +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://src/entities/behaviours/Ownership.gd" type="Script" id=1] [node name="Ownership" type="Node"] +script = ExtResource( 1 )