Refactored weapon component to handle weapon swaping.
This commit is contained in:
parent
d041531716
commit
e2cf516c90
6 changed files with 46 additions and 11 deletions
|
|
@ -19,7 +19,7 @@ func shoot():
|
|||
if total_projectiles > 0:
|
||||
for b in range(total_projectiles):
|
||||
var bullet_scene = weapon_data.bullet_scene
|
||||
var bullet := bullet_scene.instantiate() as Node
|
||||
var bullet := bullet_scene.instantiate() as Area2D
|
||||
get_tree().root.add_child(bullet)
|
||||
|
||||
# Calculate index relative to center (0 = center, -1/+1 = first from center)
|
||||
|
|
@ -42,5 +42,8 @@ func shoot():
|
|||
bullet.time_offset = time_offset
|
||||
bullet.fire_time = current_time + time_offset
|
||||
|
||||
# Set the bullet data (this is what was missing)
|
||||
bullet.set_weapon_data(weapon_data.bullet_scene, weapon_data)
|
||||
|
||||
# Subtract projectile spacing from current Player travel for next shot
|
||||
player.travel -= weapon_data.spacing
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue