Freezing a position

Butcher_of_Life

21-11-2007 17:21:42

we have a side scrolling game, where the character walks in x and negative x direction. we don't want him to be able to move in z or negative z direction. we tried
character->getNxController()->getActor()->raiseBodyFlag( NX_BF_FROZEN_POS_Z )
but he's still able to move along the z-axis, wether you tell him to, or if he collides with a object which pokes him in z direction.

why?

betajaen

21-11-2007 17:32:42

Because that could never work. It being kinematic and a Character.

Use a movement character controller to zero all of the z axis.

Butcher_of_Life

21-11-2007 17:49:31

hmm. well. we zeroed the z movement. but in case of collision with a rotated, he still gets poked in z-direction. any way to prevent that?

betajaen

21-11-2007 18:09:41

Probably not, but you could just move the character from the offset z back to zero again

Butcher_of_Life

21-11-2007 19:16:18

when I do that, a weird force is building up along the z axis. but the character doesn't respond to it. and he still moves along the z axis.
I use
NxVec3 tempVec = mTestChar->getNxController()->getActor()->getGlobalPosition();
tempVec.z = 0.0f;
mTestChar->getNxController()->getActor()->setGlobalPosition( tempVec );

betajaen

21-11-2007 19:20:46

Don't force the character to a new position; move it.

Butcher_of_Life

21-11-2007 21:13:14

well, I do move it, it's just that I always wants it to stay in Z position 0.0. I use the addmovement to move the char, but how would I move it back if it moves in Z direction?

betajaen

21-11-2007 21:24:16

Get the Z position, inverse it and add it to your movement vector.

Chebastian

22-11-2007 02:19:46

Thanks betajean!
______

Were just ready to build out first release using NxOgre but i encouter a linker error when using NxOgre::Actors.

The build completes if im not using the container, and in debug there is no problem using the container... any clues?

Error log:

Error 1 error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall NxOgre::Container<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class NxOgre::Actor *>::~Container<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class NxOgre::Actor *>(void)" (__imp_??1?$Container@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PAVActor@NxOgre@@@NxOgre@@QAE@XZ) PhysicManager.obj

Chebastian

22-11-2007 02:40:20

Update:

The problem was solved taking a pointer to Actors instead.
This error does not happen in debug....

betajaen

22-11-2007 09:13:08

I fixed this in my local copy and I thought I submitted to the SVN. It's a bug in Visual Studio that doesn't export templates properly. The solution is to force an inline to all the methods in Container.

Would you try doing this for me, and see if it compiles in Release?

Prefix every method (including constructor and destructors) with the macro "NX_INLINE", in the Container class in NxOgreContainer.h

Example:
TT get(TI t) {
if (has(t))
return items[t].t;
else
return NULL;
}

... Becomes this ...

NX_INLINE TT get(TI t) {
if (has(t))
return items[t].t;
else
return NULL;
}

Chebastian

22-11-2007 19:11:35

Yeah we had a similar problem with one of our own classes, inlining all methods in the class did the trick.

Tried putting NX_INLINE on all your methods and now its working correctly.
Thanks again. :)