Problems with buffered Input and Character control

ColeZero

04-06-2006 16:05:06

So i have switched my inputs to buffered inputs...
I've added character to the scene and know there are some poblems to controll the character.

Create Character:

mPlayer = mScene->createCharacter("Player","",Vector3(10,1,0),Vector3(0.3,1.8,0.3));
mPlayer->mNode->attachObject(mCamera);
mCamera->setPosition(Vector3(0,1.75,0));


Move Character

void OgreNXApp::keyPressed(KeyEvent* e)
{

if(e->getKey() == KC_W)
mPlayer->move(nxOgre::character::FORWARD);
}



i thougt that the move is called as long as i press the key, but it doesn't.
i have to press repeatly to move the character forward or backward....
what is wrong?

And so there is another problem with my shootBall Method, so the orientation is wrong with a character:


void OgreNXApp::ShootBall(void)
{
Vector3 dir, vec;
Quaternion orient = mCamera->getOrientation(); //getWorldOrientation() seems not to work
Vector3 pos = mCamera->getWorldPosition(); //same here getWorldPosition() do not work, don't know

vec = Vector3(0,0,-1);
dir = orient * vec;
...


its hard to explain but the ball is shooting only on the right-side of the scene.
when i look to the left side of the scene, the ball is shoot to mid of the scene i've made screens to show you what i mean.

Here iam look to the right side:the red crosshair is where im looking at,
so on this screen is everything fine:


So this is a screen from the left side, the same here crosshair is where iam looking at but the ball is shooting to mid of the scene:


Hoping you know what i mean..

betajaen

04-06-2006 16:28:09

I'd assume the buffered/unbuffered is an Ogre problem, I've always used un-buffered when it comes this thing because key presses with character control isn't crucial, rather than using it for text input.

As for your ball going to the left of the screen rather than the centre, it sounds quite familiar:

Have a look at this:

http://www.ogre3d.org/phpBB2/viewtopic. ... ht=#145559

ColeZero

04-06-2006 17:00:52

ohh crap i've recoded the complete app to use buffered Input instead of non-buffered, and nowit seems that it doesn't work anymore... oohh no..
anyway thx...but now i'll check the link, maybe it will help, also thx to this.

betajaen

04-06-2006 17:37:14

That isn't good. :D

But I think should help with your throwing sphere problem anyway.

ColeZero

04-06-2006 17:39:40

Yes it help big thx now my chararcter can walk around and shoot what i forgot was to add the pos to the direction:
So now it works perfect thx..

Vector3 dir;
Quaternion orient = mCamera->getOrientation(); //getWorldOrientation() seems not to work
Vector3 pos = mCamera->getWorldPosition(); //same here getWorldPosition() do not work, don't know
dir = orient * Vector3::NEGATIVE_UNIT_Z; //calculate the direction
Vector3 newpos = pos + dir; //!!!!!!!



Ogre::String name;
name = "Ball "+StringConverter::toString( count++ );
mCube = mScene->createBody(name,"sphere.1m.mesh",new nxOgre::sphereShape(0.5f),1.0f,Vector3(0,10,0));

mCube->setGlobalOrientation(orient);
mCube->setGlobalPosition(newpos);
mCube->addForce(dir * 2000);

betajaen

04-06-2006 17:47:46

Excellent!

Have you sorted out your buffered key input problem?

[Edit]

If I was you; I'd set the position of the sphere when you create it, it'll be more stable then.

ColeZero

04-06-2006 18:17:55

Thx for the tip..

And no unfortunately i didn't solved the problem with the buffered Input yet, but i don't give up until i or another one solved it;).
So fortunately i have a backup of my project before i switched to buffered input. :P

rUmbl3

05-06-2006 16:08:41

I got the same problem with buffered input. I solved it with

mMoveDirection.x += 1
instead of
mMoveDirection.x = 1

for example. The only big think is, you need to add 2 new move states to stop movement (I called them STOPFB and STOPSS (ForwardBackward and SideStep) and set the respective x or z values to 0, and you need to rewrite the mMoveDirection_Locked things ... i did that in simulateWalking with an Ogre::Vector3 v = Vector3(0,0,0) if its locked.

I think that should solve your problem.

ColeZero

05-06-2006 16:32:06

Well that was my problem if press W for example and move forward the character didn't stop walking forward till i press another key.
thx i think i can now use buffered input