Camera moving

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
DaRkZeAlOt
Posts: 5
Joined: Sat Oct 04, 2003 10:29 am
Location: Germany, Bremen

Camera moving

Post by DaRkZeAlOt »

Hi,
I'm trying to code a control for the camera (with WSAD). That actually looks so:

Code: Select all

class MyEventReceiver : public IEventReceiver{public: virtual bool OnEvent(SEvent event) 
  {
  core::vector3df cPos = camera->getPosition();
  
  // Falls ESC gedrückt, Programm beenden    
  if(event.EventType == EET_KEY_INPUT_EVENT &&
    event.KeyInput.Key == KEY_ESCAPE &&
	event.KeyInput.PressedDown == false) 
	device->closeDevice();
  if(event.KeyInput.Key == KEY_KEY_W)
    {
    cPos.Z+=7.5;
    camera->setPosition(cPos); 
    }
  if (event.KeyInput.Key == KEY_KEY_S) 
    { 
    cPos.Z-=7.5; 
    camera->setPosition(cPos);
    }
  if (event.KeyInput.Key == KEY_KEY_A) 
    { 
    cPos.X-=7.5; 
    camera->setPosition(cPos); 
    } 
  if (event.KeyInput.Key == KEY_KEY_D) 
    { 
    cPos.X+=7.5; 
    camera->setPosition(cPos); 
    } 
  if (event.KeyInput.Key == KEY_SPACE) 
    { 
    cPos.Y+=20; 
    camera->setPosition(cPos); 
    } 
  else
    {
    if(camera)      
      return camera->OnEvent(event);
    return false; 
    }}
  };
My problem is that the keys don't adept when i moved a bit around with the mouse. How can i adepd the keys so that the position depends on the point i'm actually looking at ?

And one more : When i press one of the keys, the camera moves one time the given value and then stops for maybe half a second after its moving normally (like known from a normal fps...). What's the reason for that ?
saigumi
Posts: 921
Joined: Fri Aug 22, 2003 11:31 am
Location: St. Louis, MO USA
Contact:

Post by saigumi »

The reason you are seeing the jumping is because you are getting the events in your keyboard "repeat delay"

Instead, what you'd want to do is assign a velocity the first time the key goes down and remove that velocity when it comes up.

This has been discussed in many threads, including this one. http://irrlicht.sourceforge.net/phpBB2/ ... 99&start=0
Crud, how do I do this again?
Post Reply