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.
Methuselah
Posts: 19 Joined: Fri Nov 24, 2006 9:33 am
Post
by Methuselah » Sat Dec 30, 2006 8:12 pm
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 » Sat Dec 30, 2006 8:37 pm
Why you just don't use the FPS camera ???
Acki
Posts: 3496 Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:
Post
by Acki » Sat Dec 30, 2006 9:21 pm
Ahh, OK...
Well, your cam only moves if you
release the key(s), because of this statement:
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)...