The Daily Click ::. Forums ::. Klik Coding Help ::. Multiple Unit Health with Counter
 

Post Reply  Post Oekaki 
 

Posted By Message

SolarB



Registered
  26/12/2011
Points
  564
3rd January, 2012 at 14:35:03 -

Hi,

For my RTS I want to have each unit of the same type (say 'soldier') have its own health bar that follows it around. One way to do this would be to have an active as the health bar with looped id checks but if I want to change the amount of health of 'soldier' then this technique is useless as I would have to redo the animation all over again etc.

Counter with horizontal bar (and pretty gradient!) functions much better but there is no way I can see of assigning IDs to counter objects.

Any thoughts?

 
My Open Source Examples: http://bit.ly/YyUFUh

Knudde (Shab)

Administrator
Crazy?

Registered
  31/01/2003
Points
  5125

Has Donated, Thank You!Clickzine StaffKlikCast StarVIP MemberGhostbuster!Dos Rules!I donated an open source project
3rd January, 2012 at 16:36:20 -

I'd say make a custom health bar out of an active object, then use that in lieu of an actual counter object. 10 frames of animation would be all you need, then set the animation as a function of the percentage of health of the unit.

Eg 18/20 Health animation #9
16/20 Health animation #8

 
Craps, I'm an old man!

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
3rd January, 2012 at 18:06:43 -

EDIT: I didn't read the first post clearly, sorry!

Edited by Del Duio

 
--

"Del Duio has received 0 trophies. Click here to see them all."

"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"

DXF Games, coming next: Hasslevania 2- This Space for Rent!

Fordom

Nordanrikets konung

Registered
  12/02/2009
Points
  190

VIP Member
4th January, 2012 at 00:31:38 -

use counter object (horiz bar).
THn you need compare the fixed value in private variable on position th e counter on for ech loop-.

 
This forum is full of trolls and disinfo agents.

Cecilectomy

noPE

Registered
  19/03/2005
Points
  305

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!ComputerBox RedSanta HatSnowman
I am an April Fool
4th January, 2012 at 00:44:06 -

shabs way is the best way to do it. you don't need any loops, except for maybe determining which bar is attached to which unit. then you just always set the animation to the percentage of the units health.

id say have at least 10 animations, 10% 20% ... 100%.

division of integers in mmf round down (iirc) so:

98 / 10 = 9.
87 / 10 = 8.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click