Starting from Energy Bar Toolkit 1.5.2 it is possible to attach bars to game objects that exist in the 3D space. Imagine 3D strategy game with many enemy objects. All these objects have separate health status. Players have the ability to select these object to check their damage value and decide which enemy should be attacked first.

Energy Bar Toolkit gives you tool to make this possible with little effort. It’s called Anchoring.

There’s a difference for anchoring support between OnGUI renderers and Mesh renderers. Please read about the type that you’re currently using.

Anchoring for the Mesh renderers

There are two approaches for anchoring Mesh renderers.

Anchor object approach

Creating an anchor for mesh bars is widely described for at mesh renderers documentation pages. Please click here to go directly to the anchoring documentation.

Pros

  • Good for 2D → 3D anchoring

Cons

  • Difficult to instantiate objects with anchored bars

Outside panel approach

This approach has been introduced in Energy Bar Toolkit 2.0.0. You can freely move your bar objects away from the panel and put it under any game object on your screen.

Here’s the video of this feature:

Anchoring for the OnGUI renderers

Anchor is nothing more and nothing less than a GameObject to which energy bar will stick. Anchor property can be found in Position & Size section of your energy bar inspector.

Setting an Anchor will set your pivot point of bar coordinate system at anchor screen position. Quite simply, this means that 0,0 will be always exactly on the object that you are anchoring to.

Additionally, next to Anchor property in your inspector, you have Anchor Camera which is the camera on which anchored object is rendered. It’s important when you’re using more than one camera because object may appear on different places on different cameras, or not appear at all.

Tips

  • It’s often a good idea to anchor energy bar objects to themselves and make them children of some bigger 3D object. In this way bar position will stay relative to 3D object. This method is described in BotRun example

Example

Launch