Post by AppThing on Jun 9, 2014 15:35:34 GMT
Hi,
I have an issue, where powerups are not positively effecting a Player Object's <Killable> Hit Points...
I use nGUI to display the WorldVariable called Health.
I have a Killable script attached to the Player Object whose initial "Hit Points" is set to Variable: Health.
To this same Player Object I have attached a script called "KillableListenerPlayer" which extends KillableListener as below (it has some more code than this, but ) condensed version is:
For the most part this works, i.e. when the player gets hit the nGUI Health value gets adjusted accordingly. However I noticed that sometimes the Player Explodes even though it's "Health" is still positive digging around I realised I have other spawned objects (PowerUps) that have a Killable attached that if hit by the player object increase the Health variable by a certain amount.
However this is not then being passed back to the Player Object's <Killable> HitPoints variable.
Q. I was wondering how this should be properly handled or how you have done this in the past?
Many thanks i advance (and let me know if any of the above is not clear
)
I have an issue, where powerups are not positively effecting a Player Object's <Killable> Hit Points...
I use nGUI to display the WorldVariable called Health.
I have a Killable script attached to the Player Object whose initial "Hit Points" is set to Variable: Health.
To this same Player Object I have attached a script called "KillableListenerPlayer" which extends KillableListener as below (it has some more code than this, but ) condensed version is:
public class KillableListenerPlayer : KillableListener
{
public Killable killable;
public HUDText hudText;
void Start()
{
if(killable == null) killable = this.GetComponent<Killable>();
{
public override void TakingDamage(int pointsDamage, Killable enemyHitBy)
{
var health = WorldVariableTracker.GetWorldVariable("Health");
health.CurrentIntValue -= pointsDamage;
base.TakingDamage(pointsDamage, enemyHitBy);
}
}
For the most part this works, i.e. when the player gets hit the nGUI Health value gets adjusted accordingly. However I noticed that sometimes the Player Explodes even though it's "Health" is still positive digging around I realised I have other spawned objects (PowerUps) that have a Killable attached that if hit by the player object increase the Health variable by a certain amount.
However this is not then being passed back to the Player Object's <Killable> HitPoints variable.
Q. I was wondering how this should be properly handled or how you have done this in the past?
Many thanks i advance (and let me know if any of the above is not clear
