Hello everybody, currently I am working on a game in 3D where the camera moves when there’s deviation of mouseX from the middle of the screen. It’s turning around the character, and when c is pressed, it switches to ego-perspective. Now I want to create a health bar, which is always in the corner of the camerascreen, but everything I try won’t work. Please help me, I am at the border of desparation.
I won’t put all of the code in this, because the Character’s shape alone is a lot of data, and she also has attacks, it would just be too much, so I’ll show you how the camera moves and how the Character moves.
void cam()
{
if(camey<5)
{camdist=200;}
xCam=(cos(mouseturn)*camdist)+xPos;
if((mouseturn2<100&mouseturn>-100)&camey==0)
{yCam=yPos+mouseturn2;}
zCam=(sin(mouseturn)*camdist)+zPos;
camera(xCam,yCam,zCam,xPos,yPos,zPos,0,1,0);
if(camey>0)
{
camdist=10;
yCam=yPos;
}
}
void moveAriel()
{
if(a1>0||a1<0)
{
xPos=(cos(mouseturn)*a1)+xPos;
zPos=(sin(mouseturn)*a1)+zPos;
}
if(c1>0||c1<0)
{
xPos=(sin(mouseturn)*c1)+xPos;
zPos=(sin(mouseturn)*c1)+zPos;
}
if(jump>0)
{
yPos=yPos+k;
if(yPos>floor-160||yPos<floor-500)
{k=-k;}
}
If you wonder, the Character is an Ariel, an air spirit, at least that’s what I’ve called her.