How To Use Varun's Entity Health, Looting System And Progress Bars

Hello and welcome to this guide on how to use Varun’s Entity Health, Looting System And Progress Bars Package!

What does this Package do?

This Package contains Scripts that allow you to:

  • Create an Entity Health System
    Add a Health Bar and Health System to physical Entities (Meshes, Shapes, NPCs)

  • Create a Looting System
    Create a Looting System that allows you to search through Entities for Loot, drop items held by the Player’s Inventory as Loot, make an Entity drop Loot when their Health reaches zero. Loot Spawning is animated using Timelines. Loot can be initialized with weighted probabilities.

  • Create a Hold to Progress Interaction System
    Create a Hold to Progress Interaction System. All features are complete with Event Bindings and SFX, VFX customization options.


SETUP

Entity Health System

1. Drag the entityHealthScript on the Entity you want to give Health to

Read the property tooltips by hovering over them with your mouse. This will explain what each property does.

2. Add the Entity Health Bar Template to your Entity as a child

image

You can customize the color of the Health Bar to whatever you want.

3. Set the Health Script properties

Now add the Entity Health Bar you just added to the “Health Bar” property

On Health Zero Settings:
There are 3 settings you can select, each of which do different things when the Entity’s Health reaches zero.

  • DestroyEntity
  • Disable Entity
  • DisableEntityAndSpawnLoot

Destroy Entity: When the Entity’s Health reaches zero, the Entity is Destroyed, it disappears from the Game World

Disable Entity: When the Entity’s Health reaches zero, the Entity stays in place, and any effects and sounds you’ve set are played.

  • If “Spawn Destroyed Template” is set to true, and a Destroyed Template is set, then the original Entity disappears and your Destroyed Template is Spawned in its place.
  • If “Launch And Explode” is set to true, the Destroyed Template is Launched with the set Impulse as if it has Exploded. You can set whether Radial Explosion Damage is applied by setting “Do Explode Damage” to true.

Disable Entity And Spawn Loot: This is the same as Disable Entity, but it also allows you to drop Loot Item Templates in a bouncy animated manner.

  • Add a Locator Entity to the “Loot Locator” property. This is where the Loot Templates will Spawn from.
  • Set whatever Templates you want to drop as Loot in the “Loot Templates” array property.
  • You can add weighted probability to the Loot Templates like Common, Uncommon, Rare, Epic, Legendary Loot etc. by adding multiple entityHealthScripts to the same Entity with different “Loot Drop Chance” values
  • “Loot Template Lifespan” is how long the Loot Templates stay in the Game World once Spawned. Set to 0 if you want the Loot Templates to stay forever.

Looting System

1. Drag the Player Looting Mode Script Folder on the Player

2. Drag the lootEntityScript on the Entity you want to make Lootable

This can be a Mesh, Shape, Trigger or NPC

3. Add a Progress Bar Template to your Entity as a child

There are two types of Progress Bar Templates you can add.
image

You can customize the color of the Progress Bar to whatever you want.

4. Set the Health Script properties

Remember to add a Locator to the “Loot Locator” property and the Progress Bar to the “Progress Bar” property

View the image in fullscreen for better clarity (click on it)

Properties:

  • “Loot Lifespan” is how long the Loot Entity stays in the Game World after Init
  • “Loot Template Lifespan” is how long the Loot Templates stay in the Game World once Spawned. Set to 0 if you want the Loot Templates to stay forever.
  • “Play Open Animation” : If the Script is attached to a Mesh which has Animations, the specified Animation will play when Looting is complete
  • “Looting Speed” : The speed at which the Player loots/finishes the interaction. Recommended value = 60, <60 is slower, >60 is faster
  • You can add weighted probability to the Loot Templates like Common, Uncommon, Rare, Epic, Legendary Loot etc. by adding multiple lootEntityScripts to the same Entity with different “Loot Drop Chance” values
  • Hold E to start Looting

5. Set the Bindings

NOTE: Please make sure that your Loot Items that are supposed to Spawn when the Player finishes Looting have pickupSpawnerScript attached with ShowOnInit And ShowOnInitInstantly set to true. Do not use UseOnCollision on pickUpSpawner Script, use a Trigger with the :Pickup() Binding instead and make sure your Loot Item is Inventory compatible like any other Inventory item, for example, the Player’s Gun.

How to make Players drop items from their Inventory as Loot

1. Add the Player Loot Trigger Spawner Script Folder on the Player

Make sure the Player Looting Mode is already present.

2. Add the Player Loot Trigger Template to the Player Loot Trigger Spawner

You can choose whether to Auto Drop Loot or not. You can also create new Templates out of the Player Loot Trigger Template to customize it however you like.

3. Add a Binding on Player Health to make them drop the Loot when they die

That’s it!

How to make NPC Enemies drop Loot

I’ve made this Package compatible with Vilva’s NPC Enemies since it’s also a popular Package.

1. Place a “NPC Loot Spawn Controller” Template for an NPC Enemy

2. Add the NPC Enemy to the “The NPC” property and the “NPC Loot Trigger” Template to the “NPC Loot Trigger Template” property

3. Add a Binding on NPC Enemy Config to make them drop the Loot when they die

That’s it!


Hold To Progress Interaction System

To create a Hold To Progress Interaction System, you just have to follow the same steps as the Looting System mentioned above, but instead of using it strictly for Loot, you can use these Events!

This is the same as:

  • WhenInteractionStarted
  • WhenInteractionFinished
  • WhenLootDropped is the same because it is sent if Loot is Spawned

Animating the Player when they’re Looting or Interacting

1. Drag the playerAnimationScript on the Entity you want the Player to be Animating while they’re Looting/Interacting with it

To pick the right Animation Strings, check out the CharacterBase PlayAction Documentation. If the Strings aren’t correct or incompatible with the API, the Player will not be animated, so make sure you pick the right one.

2. Set the Bindings

I think the properties for this Script are self-explanatory

That’s it!

This can be used to create the Generator Repairing Minigame from Harrowing High!


Congratulations on finishing this guide to the Entity Health, Looting System And Progress Bars Package!
Go ahead and Create something amazing in Crayta!

If you have any questions or suggestions, feel free to reach out to me on Crayta’s Discord at Varun#8144 I’ll be happy to jump into your Game and help you out!

2 Likes

This is a really good package, has everything someone could need. I’ll definitely play around with this some more :+1:

1 Like

Thanks brother