Moving the camera

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
Methuselah
Posts: 19
Joined: Fri Nov 24, 2006 9:33 am

Moving the camera

Post by Methuselah »

I am testing some camera movement and I could not get it to work so I just copied the code from the movement tutorial and that did not work either.
Here is the class

Code: Select all

class CameraMovement : public IEventReceiver
{
public:
-------virtual bool OnEvent(SEvent event)
-------{
--------------if (camera != 0 && event.EventType == irr::EET_KEY_INPUT_EVENT&&
---------------------!event.KeyInput.PressedDown)
--------------{
---------------------switch(event.KeyInput.Key)
---------------------{
---------------------case KEY_KEY_W:
---------------------case KEY_KEY_S:
----------------------------{
-----------------------------------core::vector3df v = camera->getPosition();
-----------------------------------v.Y += event.KeyInput.Key == KEY_KEY_W ? 2.0f : -2.0f;
-----------------------------------camera->setPosition(v);
----------------------------}
----------------------------return true;
---------------------}
--------------}
--------------return false;
-------}
};
I used '-' instead indentation
camera is the camera node defined just above the class.
Any ideas?
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Why you just don't use the FPS camera ???
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Methuselah
Posts: 19
Joined: Fri Nov 24, 2006 9:33 am

Post by Methuselah »

Because it is a RTS
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Ahh, OK... ;)

Well, your cam only moves if you release the key(s), because of this statement:

Code: Select all

!event.KeyInput.PressedDown
and then only 2 units every key release...

Also you have to call camera->updateAbsolutePosition() after you moved the cam...

Maybe you should use the boolKeys workaround for this (have a search on the forum for this)...
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Post Reply