Fixed spawning issue

This commit is contained in:
Rendo 2025-11-29 19:07:38 +05:00
commit bcb42f8d16
3 changed files with 6 additions and 11 deletions

View file

@ -14,12 +14,6 @@ properties/0/replication_mode = 1
properties/1/path = NodePath(".:rotation") properties/1/path = NodePath(".:rotation")
properties/1/spawn = true properties/1/spawn = true
properties/1/replication_mode = 1 properties/1/replication_mode = 1
properties/2/path = NodePath("StartingPistol:ammo")
properties/2/spawn = true
properties/2/replication_mode = 1
properties/3/path = NodePath("StartingPistol:remaining_ammo")
properties/3/spawn = true
properties/3/replication_mode = 1
[node name="DroppableStartingPistol" type="RigidBody3D" node_paths=PackedStringArray("weapon")] [node name="DroppableStartingPistol" type="RigidBody3D" node_paths=PackedStringArray("weapon")]
collision_layer = 8 collision_layer = 8

View file

@ -9,7 +9,6 @@ func request_spawn(data: Variant) -> Node:
return Node.new() return Node.new()
var node = load(data.scene).instantiate() var node = load(data.scene).instantiate()
if data.has("impulse"): if data.has("impulse"):
print()
if data.has_all(["ammo","remaining_ammo","slot"]): if data.has_all(["ammo","remaining_ammo","slot"]):
node.weapon.ammo = data.ammo node.weapon.ammo = data.ammo
node.weapon.remaining_ammo = data.remaining_ammo node.weapon.remaining_ammo = data.remaining_ammo

View file

@ -7,7 +7,7 @@ class_name WeaponSubStateMachine
@export var visibility_target: StringName @export var visibility_target: StringName
@export var max_ammo: int @export var max_ammo: int
@export var ammo: int: @export var ammo: int = -1:
set(value): set(value):
if value < 0: if value < 0:
ammo = 0 ammo = 0
@ -19,7 +19,7 @@ class_name WeaponSubStateMachine
get: get:
return ammo return ammo
@export var ammo_mags: int = 3 @export var ammo_mags: int = 3
@export var remaining_ammo: int: @export var remaining_ammo: int = -1:
set(value): set(value):
if value < 0: if value < 0:
remaining_ammo = 0 remaining_ammo = 0
@ -42,7 +42,9 @@ var player_camera: PlayerCamera
var player: Player var player: Player
func _ready() -> void: func _ready() -> void:
if remaining_ammo == -1:
remaining_ammo = max_ammo * ammo_mags remaining_ammo = max_ammo * ammo_mags
if ammo == -1:
ammo = max_ammo ammo = max_ammo
for child in get_children(): for child in get_children():
if child is WeaponState: if child is WeaponState: