Spawn Entity On Damage guide

This package provides you with the logic for having an entity spawn when you damage an entity. This could be used in a number of different cases depending on the game you’re creating.

How to use

  1. Download the Spawn Entity On Damage package
  2. Add the SpawnOnDamageScript to an entity in game
  3. Make sure that this entity has damageEnabled ticked in the properties
  4. In the properties select the template you wish to spawn on damaging the entity.
  5. Configure the other properties depending on how you want the script to behave
  6. Add at least 1 locator/entity to the spawnLocator array so the template has somewhere to spawn
  7. Preview and shoot/hit the entity ensuring that Apply Damage is called on it (the default gunScript will handle this for you)

There are a couple of properties on the SpawnOnDamageScript that will help customise this to fit different gameplay styles

  • hasLimit - this determines if there are a set number of spawns that can happen before no more will spawn
  • spawnLimit - this appears if hasLimit is ticked and determines the limit
  • spawnChance - this determines that chance of the template spawning each time the entity is damaged
  • spawnLocator - this array needs to have at least 1 entity in it (ideally a locator) that is used as a position/rotation in which to spawn the template. If you provide more than 1 it’ll randomly select one of them to use each time is spawns the template
  • templateToSpawn - this is the template that you want to spawn when you damage the entity

Supplies Example
Included with the package is a template called SuppliesExample. If you place one in the world you can see how it is put together as a working example. It’ll spawn a template called PhysicsBox that is a smaller cardboard box that will act under physics and drop to the ground when spawned.

Spawning lots templates quickly can greatly impact game performance so be careful not to allow players to damage an entity very quickly with high % chance of spawning the template.