Code: Select all
//Heres the function to place in a header or main.cpp
bool placeCam() {
core::vector3df campos, setcam;
float Y1, Y2, Y3, Y;
float lift = 10; //may need to change depending on speed of cam/object
campos = camera->getPosition();
Y1 = terrain->getHeight(campos.X , campos.Z);
Y2 = terrain->getHeight(campos.X+3.1 , campos.Z+3.1);
Y3 = terrain->getHeight(campos.X-.1 , campos.Z-.1);
Y = ((Y1 + Y2 + Y3)+lift)/3;
setcam = core::vector3df(campos.X, Y+5.0, campos.Z); //dont change 5.0, change lift variable
camera->setPosition(setcam);
return true;
}
//in your game loop put
placeCam();
EDIT: you need to remove your collision detector with the terrain