Code: Select all
class KeyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
if (event.EventType == EET_KEY_INPUT_EVENT)
{
if (event.KeyInput.Key == KEY_KEY_W)
{
do stuff
}
if ( event.KeyInput.Key == KEY_KEY_S)
{
do stuff
}
if (event.KeyInput.Key == KEY_KEY_D)
{
do stuff
}
if (event.KeyInput.Key == KEY_KEY_A)
{
do stuff
}
}
}
return true;
};
forward for example:
Code: Select all
float speed = 4.0;
core::vector3df v = node->getPosition();
core::vector3df r = node->getRotation();
v.X = v.X + ( cos(r.Y * 3.14/180)*speed );
v.Z = v.Z - ( sin(r.Y * 3.14/180)*speed );
node->setPosition(v);