playMaker

Author Topic: problem with GameObject referencing  (Read 1059 times)

johanesnw

  • Playmaker Newbie
  • *
  • Posts: 26
    • View Profile
problem with GameObject referencing
« on: April 20, 2014, 12:34:57 PM »
Take a look at this Prefab. It's a Poison status that will be created on contact with a spell (AoE), then attach it to each colliding object.




It has 3 FSMs.
1. Effect : this will deal damage to the attached object, that I store in GameObject variable named "target". So far no problem.
2. Duration : this will destroy self after waiting for 12s. no problem.
3. TargetDie : as in picture, this will check the "target" GameObject in Effect FSM every frame, whether its still alive or not. If the target is already dead, it will destroy self.

the problem is here. If the spell hits more than 1 enemy, then ANY enemy that dies first will destroy ALL Poison's Clone.

I tried to pause midgame, and check every Poison's target, and each is referencing different enemies.
and then I've disabled the destroy action, and see that the 1st enemy die will have it's poison target to None, and the other still referencing the target object (really obvious).
But ALL of them goes to "State 3" (see pic), which is only executed if the target gameObject is null.

Did I make mistake in "State 1"?

cwmanley

  • Full Member
  • ***
  • Posts: 107
    • View Profile
Re: problem with GameObject referencing
« Reply #1 on: April 27, 2014, 05:33:51 PM »
Hello,

This is probably not helpful, but...

Is the die transition global?

Maybe try a bool test or float compare instead of GameObject is null.