Character not turning

mnm23

08-08-2006 20:24:38

Hows it going guys. Im back with yet another problem. I am unable to turn my character node. I can turn the camera around the character. I can turn the sceneNode that attaches to the character but i am unable to turn the character. This is what i have so far.


myNinja = mScene->createCharacter("ninja1", "ninja.mesh", Vector3(10, 2, -5), Vector3(0.3, 1.8, 0.3));


This next line attaches the camera to the character.

levelCam = new CameraState(mSceneMgr, myNinja);


This line was supposed to turn the character. You can see that it tries to turn him, because the camera is slightly moving from side to side, but it as if its being forced to just keep looking straight ahead, where the characters orientation is facing.

if ( mLMouseDown )
{
myNinja->mNode->yaw( Degree( -mInputDevice->getMouseRelativeX() * 0.13) );
myNinja->mNode->pitch(Degree( -mInputDevice->getMouseRelativeY() * 0.13) );
//myNinja->turn(myNinja->mNode->getOrientation());
//myNamespace::writeF("Left Buttom.log", "Left mouse button pressed");

} // if


So i then decided to create a sceneNode to move instead of actual characterNode. Now this did turn the sceneNode and the camera follwed it whever it went but the characterNode still stayed facing the same direction. Ninja did not turn.

ninjaNode = myNinja->mNode->createChildSceneNode("NinjaNode");

//Camera attaches to sceneNode now
levelCam = new CameraState(mSceneMgr, ninjaNode);


//in frameListener
if ( mLMouseDown )
{
mRotX = Degree( -mInputDevice->getMouseRelativeX() * 0.13);
mRotY = Degree( -mInputDevice->getMouseRelativeY() * 0.13);
ninjaNode->yaw(mRotX);
//ninjaNode->pitch(mRotY);
myNinja->turn(ninjaNode->getOrientation());
}


When i take the ninjaNode out and replace it with myNinja(myNinja is character node) and i try to turn, the character will not turn but when try to move the ninja it moves in the direction i rotated the mouse but character is still facing the original orientation.

I have some images so you can get a better idea of what i am talking about, but unfortunately i am unable to upload it to my site right now. I will do so later. Thanks again for all the help guys.

Oh and one other thing i have looked through the forum here and did find aother post with almost the same problem i have, so i tried the method betajaen suggested with creating a mouseNode and not attaching it to anything. This didnt work either. Thanks again.

betajaen

08-08-2006 20:47:25

No need for screen shots I know what you mean.

The Box controller doesn't turn, for unknown reason set by Ageia it is like that. However I may be wrong but the capsule controller does.

So I'd turn your Ninja node by hand after you "turn" the character.


[Much Later Edit]

I was wrong, Both the Box and the Capsule controllers don't turn. However I've adjusted the code in Preview 4 so it automatically turns the scene node based upon the turn direction for you.

If you want to have this now, go into nxogre_character.cpp find any line that says:

mNode->setOrientation( NxTools::convert(mController->getActor()->getGlobalOrientation()));


Replace it with:

mNode->setOrientation(mDirection);

mnm23

09-08-2006 00:05:45

betajaen you rock man. Good stuff, thanks a lot. Ive been racking my brain all day today.


I do have another problem though (you're going to be so sick of me, LOL). I dont where to look in tutorial to find the correction. I have checked everywhere (i think). The problem i am having is my ninja never touches the ground. When i turn on debug i can see the bounding box and it does touch the ground but the ninjas feet are only at the half way point of the bounding box. Is there any way i can line the two up.

myNinja = mScene->createCharacter("ninja1", "ninja.mesh", Vector3(10, 2, -5), Vector3(0.3, 1.8, 0.3));


The second vector3 is the bounding box i believe(LOL), i have messed around with the numbers there and i still cant seem to adjust it. No matter what numbers i put in nothing changes. Any thoughs. Thanks again so much.

betajaen

09-08-2006 00:22:17

Yep, the Ninja.mesh is offset. It's like half a metre or so in the air.

What you can do is add a second node to the Characters Node, with a offset say 0.5 or so, then it should line up nicely.

mnm23

09-08-2006 00:32:10

Thanks for the quick response. So does this affect only the ninja.mesh or will it affect any other meshes i add in. Or i could jus try it and see for myself. LOL. Thanks for the help.

betajaen

09-08-2006 00:36:53

I think it's only the Ninja which is like that.