How do I pass an attribute from Actor to Scene? [solved]

Northfield82

  • Posts: 649
I am wanting to pass an  Attribute (Health points of Player Actor) to the Scene so I can display it as a number on the HUD.

The player health starts at 10, every time he gets hit, it decreases by 1.  This I have done, now I just want to pass that number to the scene so it can be drawn on screen (updated on the HUD).

« Last Edit: December 29, 2014, 09:05:36 am by Northfield82 »

LIBERADO

  • *
  • Posts: 2660
I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.

Northfield82

  • Posts: 649
Thanks, not quite got it working.

I have set Actor Value 'health' for self to "Quasi_Health"

Then in the scene I have 'Get Actor Value 'health' for 'MainCharacter1'

NOTE: Health is just typed in, I figured if I created a variable then I'd be back at the root of my problem...

Derelikt

  • Posts: 92
I believe that the "Set actor value" block is not for setting attributes in actor behaviors. Please see attached Screenshots, each screenshot shows a block with its explanation below it.

Northfield82

  • Posts: 649
I didn't see those descriptions! 

At the moment I'm using a Global Variable to achieve what I'm wanting to do.  But wasn't sure if this is 'best practice' and if there was a better way?

Derelikt

  • Posts: 92
Well, if you need those attributes outside this scene, then I guess using game attributes makes sense, but if you just need them in this scene, I think it's better to use local attributes. Experiment and see which works better for you.

Northfield82

  • Posts: 649
I set up a new behaviour for the Main Character to work out his health / lives but because this behaviour is attached to the actor and not the scene I couldn't pass his health points across to the scene to be drawn.

Should I not have bothered with creating the 'Quasi_Health' Behaviour and just done it all under the Scene?

Only his Lives will be past to the next scene, his health will be restored.

LIBERADO

  • *
  • Posts: 2660

I believe that the "Set actor value" block is not for setting attributes in actor behaviors. Please see attached Screenshots, each screenshot shows a block with its explanation below it.
That is not what the explanation means.

@Northfield82, Actor Values should perfectly work for your purpose. Check your code.
IMPORTANT: Place the "set actor value..." block out of the "if Quasi_Health = 0" block, not inside it.

I like to use Actor Values, but another alternative would be to use this block:

« Last Edit: December 29, 2014, 07:42:35 am by LIBERADO »
I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.

Northfield82

  • Posts: 649
Thanks Liberado, that last method worked ace! :)