//NODE = the cameranode (scenecamera....)
const f32 MOVEMENT_SPEED = 5.f;
while(device->run())
{
// Work out a frame delta time.
const u32 now = device->getTimer()->getTime();
const f32 frameDeltaTime = (f32)(now - then) / 1000.f; // Time in seconds
then = now;
core::vector3df nodePosition = node->getPosition();
if(receiver.IsKeyDown(irr::KEY_KEY_W))
nodePosition.Y += MOVEMENT_SPEED * frameDeltaTime;
else if(receiver.IsKeyDown(irr::KEY_KEY_S))
nodePosition.Y -= MOVEMENT_SPEED * frameDeltaTime;
if(receiver.IsKeyDown(irr::KEY_KEY_A))
nodePosition.X -= MOVEMENT_SPEED * frameDeltaTime;
else if(receiver.IsKeyDown(irr::KEY_KEY_D))
nodePosition.X += MOVEMENT_SPEED * frameDeltaTime;
node->setPosition(nodePosition);
driver->beginScene(true, true, video::SColor(255,113,113,133));
....
I declared then a node as camera node. When i now press "W" the camare moves to the top and not straight forward. Do u have an idea how to make it that the camera moves forward? I tested alot etc. but i dont get the solution.
It moves upwards because the Y axis is for up and down.
You have to change the X axis.
Then if you have a node that is somehow rotated you have to rotate the movement according to the nodes rotation. I bet there are snippets for this somewhere in the forums.
Software documentation is like sex. If it's good you want more. If it's bad it's better than nothing.
Go back and look at the source code for the tutorials. Nearly every one of them uses the FPS camera. The demo shows how to use a keyboard map if you want to assign different keys to the camera movement actions.
It's just all setup for you... You create an FPS camera with the scenemanager (smgr->addCameraSceneNodeFPS()) and then when you press the arrow keys it moves the camera, when you move the mouse it rotates the camera... simple as that, it's all handled within Irrlicht.
As vitek says the Demo example shows you how you can assign different keys to the movement of the FPS camera, search the example for SKeyMap and it should be clear.
JP wrote:It's just all setup for you... You create an FPS camera with the scenemanager (smgr->addCameraSceneNodeFPS()) and then when you press the arrow keys it moves the camera, when you move the mouse it rotates the camera... simple as that, it's all handled within Irrlicht.
OMG i didn't know that..im so sorry
and i looked in the demo and i searched for "KEY_KEY_W" this is why i couldn't find it.
edit://