playMaker

Author Topic: [SOLVED]Prefab dinamic variable  (Read 1370 times)

VascBogdan

  • Full Member
  • ***
  • Posts: 118
[SOLVED]Prefab dinamic variable
« on: February 07, 2015, 02:00:43 PM »
On my scene, I have like a lot of enemies, the same enemies from a prefab. I have a n EnemyHealth prefab, but it works only for an enemy.

Is there a way to create a variable for a prefab, so every single gameobject will have it's own value ? I think the solution is not to create something like: Enemy1Health, Enemy2Health, Enemy3Health.... Enemy30Health, because it would be a spam.
« Last Edit: February 08, 2015, 05:12:55 AM by VascBogdan »

VascBogdan

  • Full Member
  • ***
  • Posts: 118
Re: Prefab dinamic variable
« Reply #1 on: February 08, 2015, 05:12:36 AM »
Solved it another way.

I created a variable (not global) called HitCount. Whenever the enemy is hit, the HitCount increase with 1. When HitCount is at the maximum (the enemy health), the enemy will die.
This works with prefabs. Maybe it's helpful for someone.