DayZ like Itemsspawner

Hi everyone,

I’m currently working on a project in Unreal Engine where I’m trying to create an item spawner system inspired by games like DayZ. The system has several key features, and I’ve made some progress, but I’m stuck on a few implementation details. I’d love to get some advice or suggestions from the community!

System Overview:

  1. Zone-Based Spawn Logic:
  • The map is divided into 4 zones based on a texture (e.g., an image file where colors represent zones: Red = Zone 1, Green = Zone 2, etc.).
  • An invisible sphere acts as a spawner, checking its current zone before spawning items.
  1. Loot Tables:
  • A data structure defines which items can spawn in which zones.
  • Each item has a spawn probability and a list of allowed zones.
  1. Spawner Types:
  • Different spawner types (e.g., Industrial, Civil, Military, Medical) spawn different sets of items.
  1. Extensions:
  • Max items per zone: A limit on how many items can spawn in a zone.
  • Respawn timer: Items respawn after a set time.
  • Debugging tools: Visualize spawn zones and positions for debugging.

Current Implementation:

Zone Checking:

  • I’m using a Texture Sample node to read the zone texture.
  • The spawner’s world position is converted to pixel coordinates to determine the zone based on the texture color.

Spawn Logic:

  • A For Each Loop iterates through the loot table.
  • A Random Float in Range node checks the spawn probability for each item.

Extensions (Ideas):

  • Max items per zone: Use an array to track spawned items per zone and check the limit before spawning.
  • Respawn timer: Use a timer to respawn items after a delay.
  • Debugging tools: Use Draw Debug Sphere or Draw Debug Box to visualize zones and spawn points.

Problems and Questions:

  1. Zone Checking:
  • How can I efficiently convert the spawner’s world position to pixel coordinates to determine the zone from the texture?
  • Is there a better way to handle zone detection based on a texture?
  1. Loot Tables and Spawn Logic:
  • How can I optimize the loot table search to only spawn items allowed in the current zone?
  • What’s the best way to implement spawn probability correctly?
  1. Extensions:
  • How can I implement a max item limit per zone?
  • What’s the best way to add a respawn timer for items?
  • Are there any simple ways to visualize spawn zones and positions for debugging?

Questions for the Community:

  • Has anyone implemented a similar system before? Any tips or lessons learned?
  • Are there more efficient ways to handle zone detection based on a texture?
  • How can I optimize loot table searches and spawn probability checks?
  • Any advice on implementing max item limits, respawn timers, or debugging tools?

I’d really appreciate any help or suggestions! Thanks in advance! :blush: