Game Development Community

dev|Pro Game Development Curriculum

Adding new positions and moves; ie swim, crouch, crawl, prone

by Erik Madison · 06/23/2003 (1:33 pm) · 166 comments

This is loosely based on the only 2 forum threads I found dealing with swimming. Neither of them worked well enough for my needs, so I began this as a dirty rewrite. I also solved quite a few of my problems by reading and rereading Daniel Nielsens tutorials and resources.
I'm not real adept at showing anyone how or why I do something, so I apologize if this resource isn't as clear as it could be. I will try and work out any problems you may have.
Only 2 files are changed for the meat of the system, along with 2 scripts for a keybinding and callback access.

FILE: Which file to edit
[i]Which function to work in[/i]
surrounding original code
[b]New code[/b]
surrounding original code


FILE: Player.cc

[i]PlayerData::ActionAnimationDef PlayerData::ActionAnimationList[NumTableActionAnims] = 
{
[/i]
   { "back", { 0,-1,0 } },       // BackBackwardAnim
   { "side", { -1,0,0 } },       // SideLeftAnim,

   // These are set explicitly based on player actions
[b]
   // 6 new animations for the extreme basics   
   { "swimroot" },	
   { "swim" }, 
   { "crouchroot" },
   { "crouchforward" },
   { "crawlroot" },
   { "crawlforward" },[/b]
   { "fall" },       // FallAnim
   { "jump" },       // JumpAnim


[i]PlayerData::PlayerData()
{   
[/i]   
   minJumpSpeed = 500;
   maxJumpSpeed = 2 * minJumpSpeed;
[b]
   swimForce = 75;       
   swimEnergyDrain = 0;
   minSwimEnergy = 0;
[/b]
   horizMaxSpeed = 80;
   horizResistSpeed = 38; 

  
[i]   
bool PlayerData::preload(bool server, char errorBuffer[256])
{[/i]
   if (minJumpEnergy < jumpEnergyDrain)
      minJumpEnergy = jumpEnergyDrain;
[b]
   if (minSwimEnergy < swimEnergyDrain)
      minSwimEnergy = swimEnergyDrain;
[/b]
   // Validate some of the data
   if (recoverDelay > (1 << RecoverDelayBits) - 1) {

[i]   
void PlayerData::initPersistFields()
{
[/i]
   addField("jumpSurfaceAngle", TypeF32, Offset(jumpSurfaceAngle, PlayerData));
   addField("jumpDelay", TypeS32, Offset(jumpDelay, PlayerData));
[b]
   addField("swimForce", TypeF32, Offset(swimForce, PlayerData));
   addField("swimEnergyDrain", TypeF32, Offset(swimEnergyDrain, PlayerData));
   addField("minSwimEnergy", TypeF32, Offset(minSwimEnergy, PlayerData));
[/b]
   addField("boundingBox", TypePoint3F, Offset(boxSize, PlayerData));
   addField("boxHeadPercentage", TypeF32, Offset(boxHeadPercentage, PlayerData));
   
[i]   
void PlayerData::packData(BitStream* stream)
{[/i]
   stream->write(jumpSurfaceAngle);
   stream->writeInt(jumpDelay,JumpDelayBits);
[b]
   stream->write(swimForce);
   stream->write(swimEnergyDrain);
   stream->write(minSwimEnergy);
[/b]
   stream->write(horizMaxSpeed);
   stream->write(horizResistSpeed);
   
[i]   
void PlayerData::unpackData(BitStream* stream)
{[/i]
   stream->read(&jumpSurfaceAngle);
   jumpDelay = stream->readInt(JumpDelayBits);
[b]
   stream->read(&swimForce);
   stream->read(&swimEnergyDrain);
   stream->read(&minSwimEnergy);
[/b]
   stream->read(&horizMaxSpeed);
   stream->read(&horizResistSpeed);

   
[i]   
Player::Player()
{[/i]
   mFalling = false;
[b]   mSwimming = false;
   mPlayerPosition = 1; // 1=stand, 2=crouch, 3=prone
[/b]   mContactTimer = 0;


[i]
bool Player::onAdd()
{[/i]
   mState = NullState;
   setState(state);
[b]
   setPlayerPosition(1);   // 1=stand, 2=crouch, 3=prone
[/b]
   if (serverAnim.action != PlayerData::NullAnimation) {


[i]    
void Player::updateMove(const Move* move)
{[/i]
      }
      else
         mJumpSurfaceLastContact++;
[b]
   // Acceleration from Swimming
   // I don't understand physics, nor 3d math. Forgive me if this
   // looks horrid. It seems to work fairly well though, so I'll
   // be using it for now.   
	  if (!isMounted() && canSwim())    
	  {   
		  mSwimming = true;  // Not actually used, but perhaps good to have

		  VectorF pv;      
		  mEnergy -= mDataBlock->swimEnergyDrain;      
		  Point3F headRotation = getHeadRotation();      
		  pv = moveVec;		  
		  pv *= moveSpeed;      
		  F32 impulse = (5000 / mMass) * TickSec;   // times player.strength as well ?     
		  VectorF horiz = moveVec;         
		  horiz.normalize();         
		  horiz *= 0.9;
		  acc += horiz * impulse;         

		  VectorF swimAcc = pv - (mVelocity + acc);      
		  F32 swimSpeed = swimAcc.len();
		  F32 maxSwimAcc = (mDataBlock->swimForce / mMass) * TickSec;      
		  if (swimSpeed > maxSwimAcc) {        
			  swimAcc *= maxSwimAcc / swimSpeed;
			//  Con::errorf("Swimming too fast!");
		  }
		  if (swimSpeed > moveSpeed)
			  swimSpeed = moveSpeed;
		  acc += swimAcc;
		  acc.z = (-headRotation.x * (mDataBlock->swimForce / mMass) * 0.25f);

	  } else {
		  mSwimming = false;
	  }
[/b]      
   // Add in force from physical zones...
   acc += (mAppliedForce / mMass) * TickSec;

[i]         Further down[/i]

   if (!isGhost()) {
      // Vehicle Dismount
      if(move->trigger[2] && isMounted())
         Con::executef(mDataBlock,2,"doDismount",scriptThis());
    
      if(!inLiquid && mWaterCoverage != 0.0f) {
         Con::executef(mDataBlock,4,"onEnterLiquid",scriptThis(), Con::getFloatArg(mWaterCoverage), Con::getIntArg(mLiquidType));
[b]		 setPlayerPosition(3);[/b]
         inLiquid = true;
      }
      else if(inLiquid && mWaterCoverage <= 0.0f) {
         Con::executef(mDataBlock,3,"onLeaveLiquid",scriptThis(), Con::getIntArg(mLiquidType));
[b]		 setPlayerPosition(1);[/b]
         inLiquid = false;
      }
   } else {
      if(!inLiquid && mWaterCoverage >= 1.0f) {
[b]         setPlayerPosition(3);[/b]
         inLiquid = true;
      }   
      else if(inLiquid && mWaterCoverage < 0.5f) {
         if(getVelocity().len() >= mDataBlock->exitSplashSoundVel && !isMounted())
            alxPlay(mDataBlock->sound[PlayerData::ExitWater], &getTransform());
[b]		 setPlayerPosition(1);[/b]
         inLiquid = false;
      }
   }

                  
[i]   
bool Player::canJump()
{[/i]
	// Added position check, you cant jump while crouch, crawl
   return mState == MoveState && mDamageState == Enabled && !isMounted() && !mJumpDelay && mEnergy >= mDataBlock->minJumpEnergy && mJumpSurfaceLastContact < JumpSkipContactsMax[b] && getPlayerPosition() == 1[/b]; 
}

[b]
bool Player::canSwim()
{   
	return mState == MoveState && mDamageState == Enabled && !isMounted() && mEnergy >= mDataBlock->minSwimEnergy && mWaterCoverage >= 0.8f;
}
[/b]

[b]
void Player::setPlayerPosition(S32 position)
{
	F32 len_x, len_y, len_z;
	if (position != mPlayerPosition) {
      if (isProperlyAdded()) {

		  // Special case, this one bumps us up to the next position
		  if (position == 0) { 
			  position = mPlayerPosition + 1;
			  if (position > 3)
 				 position = 1;
		  }

         switch (position) {
         case 1: // Stand, walk
			 {				 
			 len_x = 1;
			 len_y = 1;
			 len_z = 2.3;
                         break;
			 }
 	     case 2:  // Crouch, sit
			 {
			 len_x = 1;
			 len_y = 1;
			 len_z = 1.1;        
			 break;
			 }
		 case 3:  // Crawl, prone
			 {	 
			 len_x = 1;
			 len_y = 2.3;
			 len_z = 0.7;
                         break;
			 }
         }
	 mObjBox.max.x = len_x * 0.5;
         mObjBox.max.y = len_y * 0.5;
         mObjBox.max.z = len_z;
         mObjBox.min.x = -mObjBox.max.x;
         mObjBox.min.y = -mObjBox.max.y;
         mObjBox.min.z = 0;
      }
      mPlayerPosition = position;
	}
	  if (isServerObject()) 
		setMaskBits(MoveMask);
}
[/b]


// This function needs a lot more work. It works well enough for
// basic testing/playing around purposes. Also, without quite a
// few more animations available, a more robust job here would be
// for naught.
[i]
void Player::pickActionAnimation()
{[/i]
   bool forward = true;
   U32 action = PlayerData::RootAnim;
   [b]
   if (getPlayerPosition() == 1) {
   ////////// enclosing original code in my own stuff
   
   ///////// End of original code
   }
   // Swim code, Position code
   else if (getPlayerPosition() == 2) {
	   action = (mVelocity.len() < 0.5) ? PlayerData::CrouchRootAnim : PlayerData::CrouchForwardAnim;
   }
   else if (getPlayerPosition() == 3) {
	   action = (mVelocity.len() < 0.5) ? PlayerData::CrawlRootAnim : PlayerData::CrawlForwardAnim;
	   if (mWaterCoverage != 0.0f) {
		   action = (mVelocity.len() < 0.5) ? PlayerData::SwimRootAnim : PlayerData::SwimAnim;
	   }
   }
   [/b]
   setActionThread(action,forward,false,false);
}
[i]
bool Player::updatePos(const F32 travelTime)
{[/i]
   setPosition(start,mRot);
   setMaskBits(MoveMask);
   updateContainer();
[b]
//  this prevents the rocket launch effect when a player in water surfaces
   if (mBuoyancy != 0 && mWaterCoverage <= 0.5f) 
   {   
      mVelocity.z += mBuoyancy * mGravity * mGravityMod * TickSec;

   }
[/b]
   if (!isGhost())  {


[i]   
U32 Player::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
{[/i]
[b]
	if (stream->writeFlag(mask & MoveMask)) 
		stream->writeInt(getPlayerPosition(),5);
[/b]
   if (stream->writeFlag((mask & ImpactMask) && !(mask & InitialUpdateMask)))
      stream->writeInt(mImpactSound, PlayerData::ImpactBits);
[i]        Further down......[/i]
      stream->writeFlag(mFalling);
[b]		
      stream->writeFlag(mSwimming);
[/b]
      stream->writeInt(mState,NumStateBits);


[i]
void Player::unpackUpdate(NetConnection *con, BitStream *stream)
{[/i]
[b]
	if (stream->readFlag()) {
		S32 pos = stream->readInt(5);
		setPlayerPosition(pos);
	}[/b]
   if (stream->readFlag()) 
		mImpactSound = stream->readInt(PlayerData::ImpactBits);

 [i]        Further down......[/i]
 
      mFalling = stream->readFlag();
[b]      
	  mSwimming = stream->readFlag(); // fafhrd, swim code
[/b]
      ActionState actionState = (ActionState)stream->readInt(NumStateBits);



[b][i]NEW: Updated 2/1/04 to coincide with HEAD's change to consolemethod style commands.
Change the below code (or ignore if this is your first time installing this) to what follows [/b][/i]

[i]
static S32 cgetPlayerPosition(SimObject *ptr, S32, const char **)
{
	Player* obj = static_cast<Player*>(ptr);
    return obj->getPlayerPosition();
}
static void csetPlayerPosition(SimObject *ptr, S32, const char **argv)
{
	Player* obj = static_cast<Player*>(ptr);
	obj->setPlayerPosition(dAtof(argv[2]));
}   
[/i]

void Player::consoleInit()
   Con::addCommand("Player", "getPlayerPosition", cgetPlayerPosition, "obj.getPlayerPosition()", 2, 2);
   Con::addCommand("Player", "setPlayerPosition", csetPlayerPosition, "obj.setPlayerPosition(pos)", 3, 3);


[b][i] CHANGE to this code[/b][/i]

[b]
ConsoleMethod( Player, getPlayerPosition, S32, 2, 2, "(1=stand, 2=crouch, 3=crawl)")
{
   return object->getPlayerPosition();
}

ConsoleMethod( Player, setPlayerPosition, bool, 3, 3, "(1=stand, 2=crouch, 3=crawl)")
{
   object->setPlayerPosition(dAtof(argv[2]));
}
[/b]


FILE: player.h
[i]
struct PlayerData: public ShapeBaseData {
 [/i]
    F32 jumpSurfaceAngle;      // Angle from vertical in degrees
   S32 jumpDelay;             // Delay time in ticks
 [b]  
   F32 swimForce;
   F32 swimEnergyDrain;
   F32 minSwimEnergy;
[/b]
   F32 boxHeadPercentage;
   F32 boxTorsoPercentage;
   
[i]        Further down......[/i]
   
      BackBackwardAnim,
      SideLeftAnim,

      // These are set explicitly based on player actions
[b]      SwimRootAnim,
	  SwimAnim,
	  CrouchRootAnim,
	  CrouchForwardAnim,
	  CrawlRootAnim,
	  CrawlForwardAnim,[/b]
      FallAnim,
      JumpAnim,  


[i]      
class Player: public ShapeBase
{[/i]
   ActionState mState;
   bool mFalling;                   // Falling in mid-air
[b]   bool mSwimming;
   S32 mPlayerPosition;  		    // 1=stand, 2=crouch, 3=prone   [/b]
   S32  mJumpDelay;                 // Delay till next jump

[i]        Further down......[/i]

   F32 getJumpForceModifier() { return mJumpForceModifier; }
[b]
   void setPlayerPosition(S32 pos);
   S32 getPlayerPosition() { return mPlayerPosition; }
[/b]
  protected:
   void setState(ActionState state, U32 ticks=0);
   void updateState();
   
[i]        Further down......[/i]

   bool  canJump();
[b]   bool canSwim();[/b]

   bool  haveContact()     {return !mContactTimer;}


FILE: default.bind.cs
[b]
moveMap.bind( keyboard, c, changePlayerPosition );
function changePlayerPosition(%val)
{
   if (%val)
      // calling it with a 0 will bump us up to the next position
      CommandtoServer('SetPlayerPos', 0);
}
[/b]

FILE: commands.cs
[b]
function serverCmdSetPlayerPos(%client,%pos)
{
   if (isObject(%client.player))
      %client.player.setPlayerPosition(%pos);
}
function serverCmdGetPlayerPos(%client)
{
   if (isObject(%client.player))
      return %client.player.getPosition();
   else
      return 0;
}

[/b]
#81
03/01/2006 (1:17 am)
LOL. Good stuff! Your canjump is significantly different than the resource, no position check in it (&& getPlayerPosition() == 1 ). Does yours allow jump while crouched, prone?
#82
03/01/2006 (1:29 am)
Ok I edited my response, after looking closely at the code.
By the way you could allow jump while crouch or prone, you could easily just remove the part about getPlayerPosition.
#83
03/06/2006 (3:21 pm)
I am getting multiple errors, if anyone can help that would be great,
TGE 1.4, MS C++ 6 compiler SP5

The errors:

Compiling...
player.cc
c:\torque\sdk\engine\game\player.cc(1794) : error C2143: syntax error : missing ';' before '&&'
c:\torque\sdk\engine\game\player.cc(2378) : error C2601: 'onImageRecoil' : local function definitions are illegal
c:\torque\sdk\engine\game\player.cc(2387) : error C2601: 'onUnmount' : local function definitions are illegal
c:\torque\sdk\engine\game\player.cc(2406) : error C2601: 'updateAnimation' : local function definitions are illegal
c:\torque\sdk\engine\game\player.cc(2430) : error C2601: 'updateAnimationTree' : local function definitions are illegal
c:\torque\sdk\engine\game\player.cc(2450) : error C2601: 'step' : local function definitions are illegal
c:\torque\sdk\engine\game\player.cc(2511) : error C2601: 'createInterpPos' : local function definitions are illegal
c:\torque\sdk\engine\game\player.cc(2519) : error C2601: 'updatePos' : local function definitions are illegal
c:\torque\sdk\engine\game\player.cc(2844) : error C2601: 'findContact' : local function definitions are illegal
c:\torque\sdk\engine\game\player.cc(2973) : error C2601: 'checkMissionArea' : local function definitions are illegal
c:\torque\sdk\engine\game\player.cc(3002) : error C2601: 'isDisplacable' : local function definitions are illegal
c:\torque\sdk\engine\game\player.cc(3007) : error C2601: 'getMomentum' : local function definitions are illegal
c:\torque\sdk\engine\game\player.cc(3012) : error C2601: 'setMomentum' : local function definitions are illegal
c:\torque\sdk\engine\game\player.cc(3018) : error C2601: 'getMass' : local function definitions are illegal
c:\torque\sdk\engine\game\player.cc(3028) : error C2601: 'displaceObject' : local function definitions are illegal
c:\torque\sdk\engine\game\player.cc(3074) : error C2601: 'setPosition' : local function definitions are illegal
c:\torque\sdk\engine\game\player.cc(3093) : error C2601: 'setRenderPosition' : local function definitions are illegal
c:\torque\sdk\engine\game\player.cc(3122) : error C2601: 'setTransform' : local function definitions are illegal
c:\torque\sdk\engine\game\player.cc(3136) : error C2601: 'getEyeTransform' : local function definitions are illegal
c:\torque\sdk\engine\game\player.cc(3153) : error C2601: 'getRenderEyeTransform' : local function definitions are illegal
c:\torque\sdk\engine\game\player.cc(3168) : error C2601: 'getMuzzleTransform' : local function definitions are illegal

There are more. anyway thanks in advance.
#84
03/26/2006 (2:44 pm)
I'm trying to add this to the TGE 1.4 HEAD, but the crouch and crawl animations aren't working. I'm not getting any errors in the log. Here's what I've done so far:

1) Made all the original changes/adds as Erik specified, including changes to default.bind.cs and commands.cs.
2) Did not add the cset/cgetPlayerPosition commands or the Con::AddCommand... commands since that's all deprecated under 1.4
3) Instead, did add the ConsoleMethod commands
4) Changed the setPlayerPosition console method to

ConsoleMethod( Player, setPlayerPosition, [b]void[/b], 3, 3, "(1=stand, 2=crouch, 3=crawl)")

...since setPlayerPosition returns a void.

5) Compiled, didn't receive any errors

6) Added the animation .dsq files from Jove Chiere's rar files to the server and client /data/shapes/player directories (not sure which one was supposed to be in, so added to both)

7) Updated player.cs as Dave Young suggested

Now, the swimming works, but hitting "c" on the keyboard doesn't do anything and doesn't produce any errors.... been working on this for a couple days now and I'm stumped...

any suggestions anyone? or maybe any suggestions on what I could do to even get some debug messages?

Thanks!
#85
03/26/2006 (2:53 pm)
Sounds like you forgot to add the keybind so pressing C actually does something.
In default.binds.cs
moveMap.bind( keyboard, c, changePlayerPosition );
function changePlayerPosition(%val)
{
   if (%val)
      // calling it with a 0 will bump us up to the next position
      CommandtoServer('SetPlayerPos', 0);
}

Then in server/scripts/commands.cs add...
function serverCmdSetPlayerPos(%client,%pos)
{
   if (isObject(%client.player))
      %client.player.setPlayerPosition(%pos);
}
function serverCmdGetPlayerPos(%client)
{
   if (isObject(%client.player))
      return %client.player.getPosition();
   else
      return 0;
}

Just a heads up, this resource is integrated and functional in the MMORPG Enhancement Kit.
#86
03/26/2006 (3:59 pm)
Edit: NVM, I fixed it -- gotta remember to delete those preferences when changing your key mappings :-)
#87
03/30/2006 (12:49 pm)
I just added this...works like a charm.
Thanks for the resource!
Todd
#88
05/08/2006 (10:50 am)
Edit: see next post
#89
05/08/2006 (11:53 am)
I have an issue where the player is only swimming at the center of my pond
#90
06/05/2006 (5:36 pm)
what torque version was this tested in?
#91
06/12/2006 (7:57 pm)
I have it working with tge 1.4 with TLK so its upto date. Older? cant help ya there never tried it.

Oh and my friend is trying to develop a way to change the strife on entering the water to a yawleft/right movement. It looks funny to swim to the left or right with a swim forward animation. Left and right swim animations wouldnt look much better so yaw is our awnser.
#92
06/26/2006 (9:32 am)
I just done implementing this. Works like a charm, except for the animations (wich I haven't modeled yet)
The only problem was the same as Patrick and Ben, but I solved it as suggested by Adib.

Ben and Patrick:
Quote:
player.cc(3872): error C4716: 'cPlayersetPlayerPosition' : must return a value

Adib:
Quote:
ConsoleMethod( Player, setPlayerPosition, void, 3, 3, "(1=stand, 2=crouch, 3=crawl)")
{
object->setPlayerPosition(dAtof(argv[2]));
}

Nice resource.

Bye, Berserk.
.
#93
06/29/2006 (11:12 am)
great resource - thanks to Erik Madison and everyone else !
I got this working smoothly in 1.4 with TLK
Some remarks:
- The animation sequence Dave Young mentions (Feb 18 2006) is correct, but I had to change one line to get the swimming animation really working:
sequence35 = "./animations/player_swimforward.dsq swim";
(instead of player_swim.dsq)

- Also, I had to put the keybinding line
moveMap.bind( keyboard, c, changePlayerPosition );
not only into defaults.cs, but also into config.cs to make the keybind work
Hope this can help some people when their c-key is not reacting...

Just one question: when my ork is in the water and not moving forward, he will slowly sink to the bottom if he's looking down, and rise to the surface if he's looking up. Is it possible to change the code so he stays at the same level when not moving forward?
Thanks for any ideas!
#94
07/16/2006 (8:50 pm)
Ive done a carefull implementation with this code and some custom tweeks and all is perfect for my uses, I only have one problem.

Has anyone else noticed any loss of multiplayer? I dont know if its my code or if its just like that. Do you only need to specify the sequences in player.cs to transmit the sequences over the network or is there some code somewhere i should define custom animations to transmit over the network? I had absolutly no problems with networking till this implementation.
#95
07/21/2006 (2:15 am)
#96
07/21/2006 (2:27 am)
If there is anyone having a problem like:
The code compiles and runs without an error, swim animation works when player goes into water, however, nothing happens when you press c (Change Position button)?!

This may be the solution:
I'm using fps.starter to try these stuff and I realised that I needed to change optionsDlg.cs under client folder such as:

Add following to "optionsDlg.cs" :
$RemapName[$RemapCount] = "Jump";
$RemapCmd[$RemapCount] = "jump";
$RemapCount++;
[b]
$RemapName[$RemapCount] = "Change Position";
$RemapCmd[$RemapCount] = "changePlayerPosition";
$RemapCount++;
[/b]
$RemapName[$RemapCount] = "Fire Weapon";
$RemapCmd[$RemapCount] = "mouseFire";
#97
08/11/2006 (1:20 pm)
I need help very badly. I am try to add this resource to TLK 1.4.0 but I have about 76 errors. Does anyone have the player.cc and player.h with this resource that I can look at to see what I am doing wrong.
Here some of the errors
engine\game\player.cc(2455) : error C2601: 'onImageRecoil' : local function definitions are illegal
engine\game\player.cc(2464) : error C2601: 'onUnmount' : local function definitions are illegal
engine\game\player.cc(2483) : error C2601: 'updateAnimation' : local function definitions are illegal
engine\game\player.cc(2507) : error C2601: 'updateAnimationTree' : local function definitions are illegal
engine\game\player.cc(2527) : error C2601: 'step' : local function definitions are illegal
engine\game\player.cc(2588) : error C2601: 'createInterpPos' : local function definitions are illegal
engine\game\player.cc(2596) : error C2601: 'updatePos' : local function definitions are illegal
engine\game\player.cc(2924) : error C2601: 'findContact' : local function definitions are illegal
engine\game\player.cc(3053) : error C2601: 'checkMissionArea' : local function definitions are illegal
engine\game\player.cc(3082) : error C2601: 'isDisplacable' : local function definitions are illegal
engine\game\player.cc(3087) : error C2601: 'getMomentum' : local function definitions are illegal
engine\game\player.cc(3092) : error C2601: 'setMomentum' : local function definitions are illegal
engine\game\player.cc(3098) : error C2601: 'getMass' : local function definitions are illegal
engine\game\player.cc(3108) : error C2601: 'displaceObject' : local function definitions are illegal
engine\game\player.cc(3154) : error C2601: 'setPosition' : local function definitions are illegal
engine\game\player.cc(3173) : error C2601: 'setRenderPosition' : local function definitions are illegal
engine\game\player.cc(3202) : error C2601: 'setTransform' : local function definitions are illegal
#98
08/16/2006 (12:56 am)
For clarity

if (getPlayerPosition() == 1) {
   ////////// enclosing original code in my own stuff
   
   ///////// End of original code
   }
   // Swim code, Position code
   else if (getPlayerPosition() == 2) {
	   action = (mVelocity.len() < 0.5) ? PlayerData::CrouchRootAnim : PlayerData::CrouchForwardAnim;
   }
   else if (getPlayerPosition() == 3) {
	   action = (mVelocity.len() < 0.5) ? PlayerData::CrawlRootAnim : PlayerData::CrawlForwardAnim;
	   if (mWaterCoverage != 0.0f) {
		   action = (mVelocity.len() < 0.5) ? PlayerData::SwimRootAnim : PlayerData::SwimAnim;
	   }
   }

should probably read

if (getPlayerPosition() == 1) {
   ////////// enclosing original code in my own stuff
 
    [i] if (mFalling)

    further down

    forward = false;
    }
    }
    }
    }
    }
    }[/i]

 
   ///////// End of original code
   }
   // Swim code, Position code
   else if (getPlayerPosition() == 2) {
	   action = (mVelocity.len() < 0.5) ? PlayerData::CrouchRootAnim : PlayerData::CrouchForwardAnim;
   }
   else if (getPlayerPosition() == 3) {
	   action = (mVelocity.len() < 0.5) ? PlayerData::CrawlRootAnim : PlayerData::CrawlForwardAnim;
	   if (mWaterCoverage != 0.0f) {
		   action = (mVelocity.len() < 0.5) ? PlayerData::SwimRootAnim : PlayerData::SwimAnim;
	   }
   }

Had me confused with why my animations seemed screwed up and why my swimming would only happen under certain circumstances
#99
08/17/2006 (11:59 pm)
Hi i have compiled this resource with no errors but when starting a mission it will crash the game when it finishes loading. I have checked the console and the code but their seems to be no problems. I also added animations but it still crashes. I checked default binds and everything but I still dont understand what I did wrong.
#100
09/06/2006 (6:40 am)
Thanks for the resource, it works great in 1.4!

Question: When I crouch or go prone I can fit under a DIF that I couldn't fit under while standing. However, once I'm under the DIF object and switch to standing, I get my head stuck inside of the DIF.

Before I go tearing through code and end up thinking I need to do something drastic, has anyone come across this and maybe provide a suggestion on how to fix/prevent this? I'd rather have a suggestion than a fix, so I can fix it myself and learn but it would probably be better if "fixed" so that others have it as part of a complete resource.