Game Development Community

Coop Health Bars

by Ian Roach · in Torque Game Engine Advanced · 08/08/2008 (1:12 am) · 1 replies

Anyone done such a thing ? As in 4 healthbars on your screen each representing a networked players health, when they are damaged it updates on all users screens.

Im guessing i need to heavily modify the GuiHealthBar engine source so its networkable ? Then doing some kind of schedule every x seconds locally to poll other players health status ?

Or is that overkill ?

#1
08/08/2008 (2:49 pm)
I haven't done this per se, but I did something similar -- I added a flag to the guiHealthBarCtrl to indicate if the bar was for the player, or for the selected object for the player. Basically you just need some way to tell the health bar which netconnection control object you want to use for the source.

As long as the client you're displaying the bar for knows about the other three players (that is, they've been ghosted to him), he already has their stats, so you wouldn't have to transmit any more information than you already are. By default, everythin in the zone is ghosted to every player, if I recall correctly, so unless you've got some custom ghosting rules going on, each client should already know about the other players.

By the same token, you shouldn't need to poll the other player's heath. If you modify the code in the control's onRender function, it's going to update each tick with the current status of the selected control object's health. And as the server propages current health to each client any time it changes, your stats bars should be working with the latest information.

Good luck!