Standing up and bending down in the map
Posted: Mon Aug 29, 2005 5:27 pm
Since 2 days, i'm trying to bend down an FPS camera (the player is crouching) when the CTRL key is pressed. And when the key is release, the player stands up. But my program craches at the line where i wrote "// PROBLEM"
Compilation is ok.
This is the latest version :
Someone can help me or have an other solution to do that ?
Compilation is ok.
This is the latest version :
Code: Select all
IVideoDriver* driver; //pointer to the driver
ISceneManager* smgr; //pointer to the scenemanager
ICameraSceneNode* camera; //camera
ISceneNode* node; //dummy node
ISceneNodeAnimator* anim;
ITriangleSelector* selector;
bool finProg = false; //ending the program with the ESC key
void changeCamera(vector3df vCoord)
{
//modify the view height of the player
smgr->createCollisionResponseAnimator(
selector, camera, vCoord, // vCoord<30, Height, 30>
vector3df(0,-3,0),
vector3df(0,50,0 ));
camera->addAnimator(anim);
anim->drop();
}
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
if(event.EventType == EET_KEY_INPUT_EVENT && !event.KeyInput.PressedDown){
switch(event.KeyInput.Key){
case KEY_ESCAPE:{
return finProg = true;
} break;
}
}
if(event.EventType == EET_KEY_INPUT_EVENT && event.KeyInput.PressedDown){
switch(event.KeyInput.Key){
case KEY_CONTROL :{ // crouch
changeCamera(vector3df(30,50,30));
} break;
}
}
return false;
}
};
int main()
{
// (...)
changeCamera(vector3df(30,90,30)); // PROBLEM !
while(device->run() && driver && !finProg)
{
if (device->isWindowActive())
{
driver->beginScene(true, true, SColor(0,160,200,255));
smgr->drawAll();
env->drawAll();
driver->endScene();
}
}
device->drop();
return 0;
}