one entity, multiple rendercomponents and scenenodes

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • one entity, multiple rendercomponents and scenenodes

      I browsed the forum and couldn't find where this question may have been answered previously. So sorry if it has.

      Basically, I need a health bar to be attached to an entity and need it to render and to scale it according to the health.

      So i have my 'actor' with a render component. This component has a method that creates its scenenode.
      Is it in this method that I need to include the health bar scenenode as a child?
      I need a render component for the health bar with render data and so I can update its scale based on the health values.
      I want to keep it generic as possible because I am not sure yet what I will be adding health bar's to, and an entity may include health but not necessarily render a health bar. Perhaps I just need a second rendercomponent for the entity...

      I am not sure how to handle this. Any tips will be greatly appreciated.

      kind regards.
    • The way I handle this is by creating a 'root' node for each actor, this is nice because in many editors, regardless of whether an entity has a 'render' component, it still shows things such as the transformations axes.

      Whenever you create a new render component, or change the data on one, you would simply look for the root actor (through an actor id to node lookup).
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz
    • If it were me I wouldn't attach the health bar as a child to the actor. Healthbars always face the camera directly, and tend to be drawn in the UI layer where they can't be obscured by any scene geometry (unless of course you want that to happen).

      So...I add a "follow" component to the healthbar actor that updates its position in the UI layer as the actor moves around. Odd this question came up because I just did health bars on a game a couple of weeks ago!
      Mr.Mike
      Author, Programmer, Brewer, Patriot
    • Thanks guys!

      Originally posted by mholley519
      The way I handle this is by creating a 'root' node for each actor).


      I think you are saying that I should consider having a root scene node created for every actor that would be done without the need for a render component and then listen for when render components are added and call their create scenenode() accordingly. This sounds good, I'll try it.

      Originally posted by mrmike
      I add a "follow" component to the healthbar actor


      This sounds also good. I hadn't cunsidered having the healthbar as its own actor. But I'm not sure about the communication between actor with health and healthbar actor. I guess a system would listen for events and sync them up. I'll have to try.

      Thanks guys! Much appreciated.
    • Its actually funny how the actor system fits into places that you wouldn't expect an 'actor' to go. For instance, in my 2D game Orbito, I even made the logos for the game intro actors, consider for instance something like the Rare logo in N64 games, with the big spinning golden 'Rare' plaque. Having that hard coded would work to, but why not leverage the actor system that is already in place?

      I think when it comes to UI that interacts with the positioning of the scene, actors make more sense, where if it is something like the HUD in Starcraft, using screen layers works better. In our 3D school project, since we are using Unity we are utilizing 3D objects for the user interface (anyone who uses unity knows the GUI is currently garbage). One thing that the Game Coding Complete book does not do, is have actors with a heirarchy of other actors, this would be PERFECT for your health bar as you could add a health bar to your characters as a child actor, and have it automatically follow the player around because its transformation is relative to the parent.

      There is a really good discussion on here between me and Rez a while back as I was trying to figure all of that out, if I can dig it up I will post it as it had some really cool advantages.
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz

    • One thing that the Game Coding Complete book does not do, is have actors with a heirarchy of other actors, this would be PERFECT for your health bar as you could add a health bar to your characters as a child actor, and have it automatically follow the player around because its transformation is relative to the parent.


      This is exactly how I would solve the problem. I would create an actor with a BillboardRenderComponent attached and then attach this actor as a child to anything that needed a health bar.

      -Rez
    • I ended up going with the child actor idea, and it is very tidy.
      I see the merit in the root node for each actor, but it didn't fit as nicely with what I have. But I will certainly remember it if a need arises (I haven't implemented a level editor yet).

      Thanks to all. Much appreciated.