Game Development Community

dev|Pro Game Development Curriculum

Display GuiHealthBarHud when controlled by Advanced Camera

by Eustacia Green · 08/12/2004 (10:31 am) · 1 comments

First you will need to implement the excellent advanced camera resource. I also recommend adding the AdvancedCam Orbitmode.

In game/advancedCamera.cc add:
I just put it at the end of the file.
// eag return player object used in guihealthbar
ShapeBase* AdvancedCamera::getPlayerObject()
{
   return  mPlayerObject;
}

In game/advancedCamera.h
below:
   F32 &getOrbitChangeAngle();   
   F32 &getOrbitChangeZoom();   

Add:
	// eag Method to get the player object
   ShapeBase* getPlayerObject();

and finally

In game/fps/guiHealthBarHud.cc
Change the following lines:
	if (!control || !(control->getType() & PlayerObjectType))
		return;

to:

   if (!control || !(control->getType() & PlayerObjectType))
	//	return;
      // eag
		// player is controlled by camera
		// get the player from the camera object
	{
		if (control->getType() & CameraObjectType)
		{
			control  = conn->getCameraObject();
			AdvancedCamera* camera = reinterpret_cast<AdvancedCamera*>(control);
			control = camera->getPlayerObject();
			if (!control)
				return;
		}
		else
		{
			return;
		}
	}
	// end eag

I'm not sure if I need this but I added it for good measure after #include "game/shapeBase.h":

// eag Healthbar with camera controlling player
#include "game/advancedCamera.h"

#1
08/14/2004 (4:09 am)
Eustacia, you've been doing a lot of great work lately. Thanks for the resources. :)