Welcome, Guest

Author Topic: Binding variables to the HUD  (Read 2011 times)

crydevJim

  • Posts: 4
    • View Profile
Binding variables to the HUD
« on: April 18, 2014, 02:17:48 AM »
Hi,

Can anyone tell me how to bind a variable from the game code to a variable in the HUD?

So for example, how do I update the health value on the HUD to sync with the value in the game code?

Maybe I'm blind, but I didn't find the flowgraph node in the demo sample that does this. Is there a tutorial related to this somewhere?

Thanks,
James.

Nick

  • Administrator
  • *****
  • Posts: 475
    • View Profile
Re: Binding variables to the HUD
« Reply #1 on: April 18, 2014, 03:31:15 AM »
Currently there are 2 FG nodes for that - "CoherentUI_Plugin:TriggerEvent" and "CoherentUI_Plugin:TriggerEventFloat"; the first one just fires an event with a name and the second can also pass 4 floats. You can either add more flownodes in the C++ code (src/Flownodes) that are suitable for your usage or perform binding updates directly in C++ code.

There's a lot of template magic in the binding that allows you to pass arbitrary types from JS to C++ and vice versa that has not been ported for flowgraph usage. That's why in the demo page we're using C++ to bind methods, it's much more powerful. We're actually doing the event firing in 'src/CoherentUISystem.cpp' which is not that good of a place but it works for the moment. The other direction of the binding (JS -> C++) is also not exposed for the flowgraph since it requires the address of a C++ method and I'm not sure if that's possible to specify with flownodes.
« Last Edit: April 18, 2014, 03:45:50 AM by Nick »
R&D Director @CoherentLabs

Tags: