Game Development Community

Help with breaking down Player movement

by Michael Perry · in Torque Game Engine · 02/05/2008 (12:14 pm) · 0 replies

Greetings all. I've spun myself in a circle and am now in need of some help and clarification.

After reading through Henry Todd's PhysX Player blog, I decided to take a crack at developing a PhysX Player.

My first task is to change the way the player is updated and moved, and I'm drawing my concept from Henry:
Quote:
I basically nuked every internal use of setPosition/setRenderPosition, since I want the Player to only update based on PhysX. Then I pulled the updatePos function entirely; its collision stuff isn't needed now and it gets in the way of correctly pushing objects. updateMove is then edited to:

1) apply the "acc" vector as force.
2) get mRot.z and mVelocity (which will be used in this function to calculate force) from the transform.
3) Apply move->yaw to angular velocity. Applying torque might sound like it makes more sense, but this creates a laggy control system, and we want it to be exactly the same as the stock Player.


Well, as I stated at the beginning, I have coded in circles to recreate this concept. I know what functions I need to change, and I know how to move the physX object:
// NxVec3 is nearly identical to VectorF
// Near as I can tell this would be the transform of the player modified
// by the direction we want to go in.
NxVec3 forceDir; 

// NxReal is just a float (F32)
// This is how far we are going to nudge the Player, acceleration
NxReal forceStrength = 0.0; 

// Multiply: force*direction*last interpolation time
NxVec3 forceVec = forceStrength*forceDir*dt;

// Move the internal PhysX 
mActor->actor->addForce(forceVec);

The above code allows me to move other objects around the world (when converted to a handy ConsoleMethod).

I need to take that code and apply it to the player class to move our controlled object around.

Anyone have any recommendations? Any help would be greatly appreciated, and as always, thanks in advance.