FPS Camera don't stop !!!

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
nobpn
Posts: 7
Joined: Wed Jun 14, 2006 3:56 pm
Location: France - Dijon

FPS Camera don't stop !!!

Post by nobpn »

Hello,

I'm a frenchie guy so my english...

I have a little probleme with the fps camera,
- when the buttons of the mouse are released, i want to click the buttons, scrool the bars...
- when right button is pressed, i want to control my camera.

To do that i write :

Code: Select all

else if (event.EventType == EET_MOUSE_INPUT_EVENT )
{
    switch(event.MouseInput.Event)
    {
        ICameraSceneNode* camera = device->getSceneManager()->getActiveCamera();

        case EMIE_RMOUSE_PRESSED_DOWN  :
            if ( camera != 0)
            {
                camera->setInputReceiverEnabled(true);
                device->getCursorControl()->setVisible(false);
             }
             break;

        case EMIE_RMOUSE_LEFT_UP   :
                if (camera != 0)
                {
                    camera->setInputReceiverEnabled(false);
                    device->getCursorControl()->setVisible(true);
                }
                break;
    } 
}
In fact with this code if a push on the UP arrow, my camera move forward, all right :D but if i release the mouse button BEFORE release the UP arrow, the camera still advance without any actions...

Please help :roll:

Thanks.
thePyro_13
Posts: 1
Joined: Fri Jun 23, 2006 2:00 pm

Post by thePyro_13 »

hi, im new to programming(so if this is wrong dont be mad :S) but i think mabe you should be useing a WHILE loop to check if both the mouse button and the UP key is down before moving the camera

ie.

Code: Select all

the rest of your code

while(rightmousebuttondown AND Keydown)
{
   code for moving camera
}

whatever else is after the movment code

but still, I am new at this so dont be suprised if this is incorrect
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Nope, the problem is that you disable the event receiver such that the key up will be lost and movement won't stop. Just call the stop action when receiving the mouse up, too.
nobpn
Posts: 7
Joined: Wed Jun 14, 2006 3:56 pm
Location: France - Dijon

Post by nobpn »

Hello

I don't anderstand what is the "stop action" ???
When I disable the event receiver, I don't know why the key up is lost and why camera don't stop.

I try this :

Code: Select all

case EMIE_RMOUSE_LEFT_UP   :
    if (camera != 0)
    {
        camera->setInputReceiverEnabled(false);
        device->getCursorControl()->setVisible(true);


        //NEW
        camera->setTarget(camera->getTarget());
        camera->setPosition(camera->getPosition());
    }
    break;
But repositioning the target and position don't change something.

@hybrid => don't you have some pieces of code ? :D

Thanks for your responses.

Bye
t0mmy
Posts: 10
Joined: Wed Jun 21, 2006 9:44 am
Location: Tuebingen, Germany
Contact:

Post by t0mmy »

Code: Select all

camera->setInputReceiverEnabled(false); 
here you disable the event receiver... so when you release the arrow-up key, no event will be created.

The event receiver gets alls inputs, not only from the mouse.
nobpn
Posts: 7
Joined: Wed Jun 14, 2006 3:56 pm
Location: France - Dijon

Post by nobpn »

OK!!!!!!!!!!!!!!!!!!!!!!

I did this now :

Code: Select all

SEvent event;
event.EventType = EET_KEY_INPUT_EVENT;
event.KeyInput.Key = KEY_UP;
event.KeyInput.PressedDown = false;

Camera->OnEvent(event);
Now my camera stop alright !!!

Thanks to all !

bye!
Post Reply