pickup item values are assigned through level editor and spawn correctly, now need to implement non random spawns

This commit is contained in:
Derek
2025-01-16 23:09:57 -06:00
parent 0a3bdd26d4
commit cafcf57ef1
7 changed files with 53 additions and 28 deletions

View File

@@ -206,7 +206,15 @@ func quiet_remove():
func drop_loot(number_of_drops):
#pickup drop
while number_of_drops > 0:
var rand_item = level_control.pickup_spawn()
var pickup_spawn = level_control.item_pickup.instantiate()
var item_stats = level_control.pickup_spawn()
##SET VARIABLES
pickup_spawn.pickup_type = item_stats["pickup_type"]
pickup_spawn.ammo_type = item_stats["ammo_type"]
pickup_spawn.value = item_stats["value"]
var lv_x = randf_range(-MAX_LV,MAX_LV)
var lv_y = randf_range(0,MAX_LV)
var lv_z = randf_range(-MAX_LV,MAX_LV)
@@ -215,12 +223,12 @@ func drop_loot(number_of_drops):
var av_z = randf_range(-MAX_AV,MAX_AV)
# Random Item Drop
rand_item.position = self.global_position + Vector3(0,2,0) #added height to spawn location since origin is on the ground
rand_item.transform.basis = self.global_transform.basis
rand_item.linear_velocity += self.global_transform.basis * Vector3(lv_x,lv_y,lv_z)
rand_item.angular_velocity += self.global_transform.basis * Vector3(av_x,av_y,av_z)
pickup_spawn.position = self.global_position + Vector3(0,2,0) #added height to spawn location since origin is on the ground
pickup_spawn.transform.basis = self.global_transform.basis
pickup_spawn.linear_velocity += self.global_transform.basis * Vector3(lv_x,lv_y,lv_z)
pickup_spawn.angular_velocity += self.global_transform.basis * Vector3(av_x,av_y,av_z)
await get_tree().create_timer(.05).timeout
get_tree().get_root().add_child(rand_item)
get_tree().get_root().add_child(pickup_spawn)
number_of_drops -= 1
if number_of_drops <= 0: