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.
LarryTM
Posts: 8 Joined: Wed Aug 17, 2005 10:26 am
Location: Warsaw, Poland.
Contact:
Post
by LarryTM » Fri Sep 09, 2005 11:30 am
Hi,
im working on 'diablo clone' game and i have problem with smooth camera rotating. When i try to rotate my camera - i dont have smooth rotate - i have step rotating. like when you want to use int instead of float. I use CameraSceneNode.
My code is :
Code: Select all
float ile;
float ile_up;
class MyEventReceiver : public IEventReceiver
{
virtual bool OnEvent(SEvent event)
{
if (event.EventType == irr::EET_KEY_INPUT_EVENT)
{
switch(event.KeyInput.Key)
{
case KEY_LEFT: { ile=ile+5.0; } return true;
case KEY_RIGHT: { ile=ile-5.0; } return true;
case KEY_UP: { ile_up=ile_up+0.1; } return true;
case KEY_DOWN: { ile_up=ile_up-0.1; } return true;
}
}
return false;
}
};
- AND in MainLoop -
Code: Select all
kamera_promien=kamera_promien+ile_up;
core::vector3df v = camera->getPosition();
v.X=kamera_promien*sin(ile* core::PI/180.0f);
v.Z=kamera_promien*cos(ile* core::PI/180.0f);
v.Y=v.Y+ile_up;
camera->setPosition(v);
What is wrong?
thanks for help!
/lar
Spintz
Posts: 1688 Joined: Thu Nov 04, 2004 3:25 pm
Post
by Spintz » Fri Sep 09, 2005 1:14 pm
Instead of moving the camera 5.0 units every time the key is pressed, change it so that the camera move at a rate, or units / second. Then each frame, move the camera by - 5.0 units / number of seconds elapsed since last frame.
Guest
Post
by Guest » Fri Sep 09, 2005 6:18 pm
I try but it didnt help.
it looks like - when you try to rotate by pressing left or right key very fast instead of keeping it pressed.
/lar
Spintz
Posts: 1688 Joined: Thu Nov 04, 2004 3:25 pm
Post
by Spintz » Fri Sep 09, 2005 6:33 pm
I don't understand that last comment, can you clarify please!
Spintz
Posts: 1688 Joined: Thu Nov 04, 2004 3:25 pm
Post
by Spintz » Fri Sep 09, 2005 6:33 pm
I don't understand that last comment, can you clarify please!
Dances
Posts: 454 Joined: Sat Jul 02, 2005 1:45 am
Location: Canada
Contact:
Post
by Dances » Fri Sep 09, 2005 7:34 pm
Have you been using updateAbsolutePosition() on your camera and nodes? Lots of people have jittery movement troubles without this.
Guest
Post
by Guest » Fri Sep 09, 2005 7:48 pm
Ok, here is the sample ->
www.temporary.art.pl/test.zip
Try up and down keys and page_up, page_down -> the camera moves smooth.
Try left and right keys -> its sucks.
Why?
/lar
Dances
Posts: 454 Joined: Sat Jul 02, 2005 1:45 am
Location: Canada
Contact:
Post
by Dances » Fri Sep 09, 2005 7:52 pm
Spintz was right, Using a rotation of 5 is your trouble.
case KEY_LEFT: { ile=ile+5.0; } return true;
case KEY_RIGHT: { ile=ile-5.0; } return true;
should be more like
case KEY_LEFT: { ile=ile+0.1; } return true;
case KEY_RIGHT: { ile=ile-0.1; } return true;
as you did with UP/DOWN.
Guest
Post
by Guest » Fri Sep 09, 2005 7:54 pm
In this demo (test.zip) code is :
case KEY_LEFT: { ile=ile+0.1; }; return true;
case KEY_RIGHT: { ile=ile-0.1; } return true;
/lar
Dances
Posts: 454 Joined: Sat Jul 02, 2005 1:45 am
Location: Canada
Contact:
Post
by Dances » Sat Sep 10, 2005 12:06 am
a value of 0.1 wouldn't make it move 9-10 units every time you hit the button, but thats what the value on top of the screen says.
Its curious though I just noticed that the key repeat effects left and right whereas up and down aren't affected, you might want to follow the keys tutorial in the wiki, it might help you fix it.