Movement HELP
Movement HELP
Can someone create for me a sample source for player movement(camera follow player) my englisch ist no good and i cant understand tutorial in this site :/ HELP
The camera doesnt 'follow' the player.
should be enough. this is assuming your scenemanager goes by the name scenemgr.
-dudMan
Code: Select all
scenemgr->addCameraSceneNodeFPS();
-dudMan
i think might be able todo something like that, but ive never used it before.
Code: Select all
scenemgr->addCameraSceneNodeMaya()
No liger13 this will not help. Maya camera is just first person with click and drag. I think this here will help you http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=18074
or
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=19282
or
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=19282
@up
thanks man but i cant compile WoW movements :/ i have error
@topic
where i can put this code :
in my code :
thanks man but i cant compile WoW movements :/ i have error
@topic
where i can put this code :
Code: Select all
#define RUN_SPEED 10
void Controls::keyDown(int key, bool b)
{
keysDown[key] = b;
}
void Controls::movementUpdate(void)
{
vector3df moveLoc;
vector3df ax1;
vector3df ax2;
if(keysDown[KEY_KEY_W] && keysDown[KEY_KEY_D])
{
ax1 = vector3df(0, 0, 1 * RUN_SPEED);
vEngine->cam->getAbsoluteTransformation().rotateVect(ax1);
ax2 = vector3df(1 * RUN_SPEED, 0, 0);
vEngine->cam->getAbsoluteTransformation().rotateVect(ax2);
moveLoc = vEngine->cam->getAbsolutePosition() + ax1 + ax2;
moveLoc.Y = vEngine->cam->getAbsolutePosition().Y;
}
if(keysDown[KEY_KEY_W] && keysDown[KEY_KEY_A])
{
ax1 = vector3df(0, 0, 1 * RUN_SPEED);
vEngine->cam->getAbsoluteTransformation().rotateVect(ax1);
ax2 = vector3df(1 * RUN_SPEED, 0, 0);
vEngine->cam->getAbsoluteTransformation().rotateVect(ax2);
moveLoc = vEngine->cam->getAbsolutePosition() + ax1 - ax2;
moveLoc.Y = vEngine->cam->getAbsolutePosition().Y;
}
if(keysDown[KEY_KEY_S] && keysDown[KEY_KEY_D])
{
ax1 = vector3df(0, 0, 1 * RUN_SPEED);
vEngine->cam->getAbsoluteTransformation().rotateVect(ax1);
ax2 = vector3df(1 * RUN_SPEED, 0, 0);
vEngine->cam->getAbsoluteTransformation().rotateVect(ax2);
moveLoc = vEngine->cam->getAbsolutePosition() - ax1 + ax2;
moveLoc.Y = vEngine->cam->getAbsolutePosition().Y;
}
if(keysDown[KEY_KEY_S] && keysDown[KEY_KEY_A])
{
ax1 = vector3df(0, 0, 1 * RUN_SPEED);
vEngine->cam->getAbsoluteTransformation().rotateVect(ax1);
ax2 = vector3df(1 * RUN_SPEED, 0, 0);
vEngine->cam->getAbsoluteTransformation().rotateVect(ax2);
moveLoc = vEngine->cam->getAbsolutePosition() - ax1 - ax2;
moveLoc.Y = vEngine->cam->getAbsolutePosition().Y;
}
if(keysDown[KEY_KEY_W] && !keysDown[KEY_KEY_A] && !keysDown[KEY_KEY_D] && !keysDown[KEY_KEY_S])
{
ax1 = vector3df(0, 0, 1 * RUN_SPEED);
vEngine->cam->getAbsoluteTransformation().rotateVect(ax1);
moveLoc += vEngine->cam->getAbsolutePosition() + ax1;
moveLoc.Y = vEngine->cam->getAbsolutePosition().Y;
}
if(keysDown[KEY_KEY_S] && !keysDown[KEY_KEY_A] && !keysDown[KEY_KEY_D] && !keysDown[KEY_KEY_W])
{
ax1 = vector3df(0, 0, 1 * RUN_SPEED);
vEngine->cam->getAbsoluteTransformation().rotateVect(ax1);
moveLoc += vEngine->cam->getAbsolutePosition() - ax1;
moveLoc.Y = vEngine->cam->getAbsolutePosition().Y;
}
if(keysDown[KEY_KEY_D] && !keysDown[KEY_KEY_A] && !keysDown[KEY_KEY_S] && !keysDown[KEY_KEY_W])
{
ax1 = vector3df(1 * RUN_SPEED, 0, 0);
vEngine->cam->getAbsoluteTransformation().rotateVect(ax1);
moveLoc += vEngine->cam->getAbsolutePosition() + ax1;
moveLoc.Y = vEngine->cam->getAbsolutePosition().Y;
}
if(keysDown[KEY_KEY_A] && !keysDown[KEY_KEY_S] && !keysDown[KEY_KEY_D] && !keysDown[KEY_KEY_W])
{
ax1 = vector3df(1 * RUN_SPEED, 0, 0);
vEngine->cam->getAbsoluteTransformation().rotateVect(ax1);
moveLoc += vEngine->cam->getAbsolutePosition() - ax1;
moveLoc.Y = vEngine->cam->getAbsolutePosition().Y;
}
if(!keysDown[KEY_KEY_W] && !keysDown[KEY_KEY_S] && !keysDown[KEY_KEY_A] && !keysDown[KEY_KEY_D])
{
moveLoc = vEngine->cam->getAbsolutePosition();
}
vEngine->cam->setPosition(moveLoc);
}
bool Controls::OnEvent(SEvent event)
{
if(event.EventType == EET_KEY_INPUT_EVENT)
{
//Keyboard events here
if(event.KeyInput.PressedDown)
{
keyDown(event.KeyInput.Key, true);
movementUpdate();
}
else
{
for(int i = 0; i < 256; i++)
keyDown(i, false);
}
}
return true;
}
Code: Select all
#include <stdio.h>
#include <wchar.h>
#include <irrlicht.h>
#pragma comment(lib, "Irrlicht.lib")
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
int main()
{
createDevice(EDT_SOFTWARE, dimension2d<s32>(600, 600), 16,
false, false, false, 0);
device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
guienv->addStaticText(L"Hello World! This is the Irrlicht Software engine!",
rect<int>(10,30,200,44), true);
IAnimatedMesh* cam = smgr->getMesh("media/tris.md2");
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( cam );
if (node)
{
node->setMaterialFlag(EMF_LIGHTING, false);
node->setFrameLoop(0, 310);
node->setMaterialTexture( 0, driver->getTexture("media/alien.pcx") );
}
smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
while(device->run())
{
driver->beginScene(true, true, SColor(255,100,101,140));
smgr->drawAll();
guienv->drawAll(); driver->endScene();
}
device->drop(); return 0;
}
thats part of an eventReciever class i think. just add it to the device with
Code: Select all
device->setEventReceiver();