[SOLVED] NaN when trying to Hit Enemy

twinter3

  • Posts: 98
I am getting NaN when trying to apply hitpoints to an enemy.  If I just insert a number into the Actor Message block (shown) it works fine.  However, if I try and subtract from the attribute (as a number), it returns NaN. (Shown to the right of the block)  It won't allow me to subtract from an attribute without the "as a number" block (Shown to the right of the block)  Just need some guidance on this one.  Thanks!!!


« Last Edit: February 09, 2012, 09:28:27 am by twinter3 »

coleislazy

  • *
  • Posts: 2607
When you type "_enemyCurrentHealth" into a block, it will evaluate as the literal text. If you want to refer to an attribute by code, you need to wrap it in a code block first.

However, in this case it seems like you are referring to an attribute in another behavior. Instead, you would use the appropriate "getter" message block to get the attribute, in the same way as you are currently using the "setter" message block.

In short, replace the text you typed with the a "getter" block.

twinter3

  • Posts: 98
Thanks!  It worked.