Spawn actors with health bars

drixz97462drixz97462 Member Posts: 10
edited November -1 in Working with GS (Mac)
Hello,

I'm just wondering if there's a way to spawn actor with health bars. Currently I'm doing it via the wiki way which sets a game attribute of targetX, targetY that positions the health bar to an actor. However making another actors that spawns the same health bar would result a black screen when previewed.

Comments

  • JGary321JGary321 Member Posts: 1,246
    Constrain X & Y of the mobs you want to spawn the bar to. You can use the same game attribute for all the mobs. Make a rule under the mob that spawns HP Bar. Under your HP Bar set 2 constrain attributes. Set one to Constrain X to game.X (or whatever u called it), Set the other to Constrain Y to game.Y

    Again you CAN use the same X, Y for different types of mobs or ever multiple instances of mobs. The program keeps track & constrains it to each instance. I only have 1 game.(X, Y) for all my HP bars.

    Presto all done.
  • drixz97462drixz97462 Member Posts: 10
    I'm not too sure if I got it correct... since the HP Bar would just be spawned by the first mob or actor on screen. Subsequent actors that on the screen would not spawn their own HP Bar.

    What I'm currently doing in summary are as follows:

    1. Create game attributes: TargetX and TargetY
    2. Set Actor Constrain:: game.TargetX = self.Position.X, game.TargetY = self.PositionY+25
    3. Set HP Bar Constrain: self.Position.X = game.TargetX, self.Position.Y = game.TargetY

    I would appreciate if someone could point me to the right direction. Btw thanks for your reply JGary321! :)
  • drixz97462drixz97462 Member Posts: 10
    After a few experiments I think there might be some problem with my GameSalad app...

    I tried to make two different actors to spawn another two different actors on the screen. But it turns out that only one actor would spawn and another wouldn't.

    Say there are 4 actors as seen in the inspector, namely Actor 1, Actor 2, Actor A and Actor B. Both Actor A and Actor B are created without any behavior and rule.

    Now I want Actor 1 to spawn Actor A, and Actor 2 to spawn Actor B on screen. I created a Spawn Actor behavior for each specifically and then dragged both Actor 1 and 2 down on the scene.

    The result: Actor 1 spawns Actor A, but Actor 2 spawns nothing.
  • drixz97462drixz97462 Member Posts: 10
    LOL I've just solved my own problem. Again thanks a JGary321!
  • JGary321JGary321 Member Posts: 1,246
    No prob, sorry I haven't been on all day (relatives in town), but I'm glad you got this sorted out.
  • drixz97462drixz97462 Member Posts: 10
    Just ran into another relevant issue...

    The health bars of BOTH Actor'A' and Actor'B' shrinks when ONLY ONE of them is attacked by a mob. Note that both Actor 'A' and Actor 'B' shares the same attributes and behaviors, 'B' can be said as a copy of 'A'.

    I have a game variable called game.HP. So when one receives an attack the (game.HP = game.HP -1).

    Is there any way to counter this issue?
  • drixz97462drixz97462 Member Posts: 10
    Just solved my own issue again...

    Seems to be the issue of putting game.Max HP variable as a condition of a rule.
Sign In or Register to comment.