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
FILE: Player.cc
FILE: player.h
FILE: default.bind.cs
FILE: commands.cs
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]About the author
Recent Blogs
• Dynamic GUI• Mob Look
• Faster Polysoup
• DreamGames and Titas
• Working with pickActionAnimation()
#102
09/16/2006 (1:05 pm)
this code was not ment for version 1.4 works fine with 3.x
#103
When my player stay in crouchroot pose....the weapon not see...
See only when i take down the my see....
WHY i have this error?
thanks
09/19/2006 (6:32 am)
I have a problem....When my player stay in crouchroot pose....the weapon not see...
See only when i take down the my see....
WHY i have this error?
thanks
#104
www.grafosyakuza.com/wc/temp/prone.rar
Just linking the animations for orc for you guys. Make sure when you do a 'save as' you change it from a .htm extension to a .rar (don't know why we have to, but it's savin them as .htm for some reason)
10/16/2006 (6:58 am)
jovechiere.no-ip.com/wc/temp/swimming%2Bcrouch.rarwww.grafosyakuza.com/wc/temp/prone.rar
Just linking the animations for orc for you guys. Make sure when you do a 'save as' you change it from a .htm extension to a .rar (don't know why we have to, but it's savin them as .htm for some reason)
#105
10/16/2006 (5:55 pm)
In TSE ms4 when I add anything past 35 animation sequences I get overflow errors:*** New Mission: starter.mmo/data/missions/stronghold.mis *** Phase 1: Download Datablocks & Targets Mapping string: MissionStartPhase1Ack to index: 0 Error: shape starter.mmo/data/shapes/crossbow/ammo.dts-collision detail 1 (Collision-3) bounds box invalid! [b]Fatal: (...\engine\core\bitstream.cpp @ 194) Out of range write[/b]
#106
where bufSize is:
As an update for anyone curious if this will work in TSE, I have it up and running (outside of above issue) with prone and crouch working. Swimming isn't working yet, so tracking that down now =)
10/16/2006 (6:11 pm)
Upon looking a little further, I found that the bitstream is tossing the range problem and is set as:maxReadBitNum = bufSize << 3;
where bufSize is:
bufSize = getPosition() + mMinSpace * 2;
dataPtr = (U8 *) dRealloc(dataPtr, bufSize);As an update for anyone curious if this will work in TSE, I have it up and running (outside of above issue) with prone and crouch working. Swimming isn't working yet, so tracking that down now =)
#107
10/16/2006 (6:35 pm)
The TSE ms4 issues documented here: www.garagegames.com/mg/forums/result.thread.php?qt=52414
#108
11/15/2006 (9:34 pm)
Has anyone tried this with TGE 1.5? I tried to add in the changes, but ended up a little confused since the player.cc and player.h seem to have changed rather significantly from the example.
#109
By crouch-like, I mean that the collision box is half the height as the original.
This is the problem. If my player is underneath a bridge while in the crouch-like state and that player jumps, collision resolution quirk occurs. It seems that the player's old bounding-box is considered for the collision detection, but the new bounding-box is used to place the character underneath the bridge. So, instead of the player "bumping his head" under the bridge, an awkward snap occurs whereby the player is instantly placed underneath the bridge. The player then falls back down to the ground.
I've focused mainly on these lines of code:
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;
onScaleChanged();
if(isServerObject())
setMaskBits(MoveMask);
Are there any other functions required to update the bounding box after mObjBox's member variables are modified?
11/20/2006 (6:50 pm)
I am having a problem with changing the player collision box through scripting. I've added all the necessary functions that are outlined in this resource. I've created console commands and binded keys to the commands. The collision box appears to get smaller when I try to go into a crouch-like state.By crouch-like, I mean that the collision box is half the height as the original.
This is the problem. If my player is underneath a bridge while in the crouch-like state and that player jumps, collision resolution quirk occurs. It seems that the player's old bounding-box is considered for the collision detection, but the new bounding-box is used to place the character underneath the bridge. So, instead of the player "bumping his head" under the bridge, an awkward snap occurs whereby the player is instantly placed underneath the bridge. The player then falls back down to the ground.
I've focused mainly on these lines of code:
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;
onScaleChanged();
if(isServerObject())
setMaskBits(MoveMask);
Are there any other functions required to update the bounding box after mObjBox's member variables are modified?
#110
http://www.garagegames.com/mg/forums/result.thread.php?qt=5180
12/06/2006 (12:16 am)
For anyone who is encountering a Fatal: (...\source\engine\core\bitstream.cpp @ 194) Out of range writeLook here for the fix.
http://www.garagegames.com/mg/forums/result.thread.php?qt=5180
#111
12/06/2006 (7:24 am)
EDIT: removed
#113
Well I did have a problem where nothing worked but I figured it all out.
Got the swimming to work as soon as the orc enters the water, and the fatal crash on gameconnection.
Now I just need to get some advise on the crawling part. If the player is crouched or is on a crawl, man can he move fast! lol
How can I slow him down when his position is crawl or crouch?
Also how can I stop him from going into crawl or crouch when he is swimming?
Thanks
01/01/2007 (6:38 pm)
EDIT:Well I did have a problem where nothing worked but I figured it all out.
Got the swimming to work as soon as the orc enters the water, and the fatal crash on gameconnection.
Now I just need to get some advise on the crawling part. If the player is crouched or is on a crawl, man can he move fast! lol
How can I slow him down when his position is crawl or crouch?
Also how can I stop him from going into crawl or crouch when he is swimming?
Thanks
#114
in player.cc, in updateMove under
add
and change
to look like this
And for the second question you can check if the player is in the water or not by this variable "mWaterCoverage". If he is in the water don't change the PlayerPos.
:)
Aun.
01/02/2007 (10:41 pm)
@ Louis Dufresne a super hacky (and hard coded) way you can do to slow him down is by thisin player.cc, in updateMove under
MatrixF zRot; zRot.set(EulerF(0, 0, mRot.z));
add
F32 tempSpeedMult = 1 ; F32 tempForceMult = 1 ; if(getPlayerPos() == 2) tempSpeedMult = 0.8 ; else if(getPlayerPos() == 3) tempSpeedMult = 0.2 ;
and change
if (move->y > 0)
{
if( mWaterCoverage >= 0.9 )
moveSpeed = getMax(mDataBlock->maxUnderwaterForwardSpeed * move->y,
mDataBlock->maxUnderwaterSideSpeed * mFabs(move->x));
else
moveSpeed = getMax(mDataBlock->maxForwardSpeed * move->y,
mDataBlock->maxSideSpeed * mFabs(move->x));
}
else
{
if( mWaterCoverage >= 0.9 )
moveSpeed = getMax(mDataBlock->maxUnderwaterBackwardSpeed * mFabs(move->y),
mDataBlock->maxUnderwaterSideSpeed * mFabs(move->x));
else
moveSpeed = getMax(mDataBlock->maxBackwardSpeed * mFabs(move->y),
mDataBlock->maxSideSpeed * mFabs(move->x));
}to look like this
if (move->y > 0)
{
if( mWaterCoverage >= 0.9 )
moveSpeed = tempSpeedMult* getMax(mDataBlock->maxUnderwaterForwardSpeed * move->y,
mDataBlock->maxUnderwaterSideSpeed * mFabs(move->x));
else
moveSpeed = tempSpeedMult* getMax(mDataBlock->maxForwardSpeed * move->y,
mDataBlock->maxSideSpeed * mFabs(move->x));
}
else
{
if( mWaterCoverage >= 0.9 )
moveSpeed = tempSpeedMult * getMax(mDataBlock->maxUnderwaterBackwardSpeed * mFabs(move->y),
mDataBlock->maxUnderwaterSideSpeed * mFabs(move->x));
else
moveSpeed = tempSpeedMult * getMax(mDataBlock->maxBackwardSpeed * mFabs(move->y),
mDataBlock->maxSideSpeed * mFabs(move->x));
}And for the second question you can check if the player is in the water or not by this variable "mWaterCoverage". If he is in the water don't change the PlayerPos.
:)
Aun.
#115
HotB/server/scripts/commands.cs (69): Unknown command setPlayerPosition.
Object (1450) Player -> ShapeBase -> GameBase -> SceneObject -> NetObject -> SimObject
Any ideas what I could have done wrong?
01/15/2007 (2:35 pm)
Im getting the error:HotB/server/scripts/commands.cs (69): Unknown command setPlayerPosition.
Object (1450) Player -> ShapeBase -> GameBase -> SceneObject -> NetObject -> SimObject
Any ideas what I could have done wrong?
#116
01/15/2007 (3:45 pm)
I am using TSE
#117
Turning renderFirstPerson = true showed something interesting. It seams when i crouch and look down, i see the feet tuck up but the player remains in position, prone appears as if the client is standing.
What the heck!? Anyone have any ideas what is wrong?
01/22/2007 (8:43 pm)
I am using TSE 1.5 and have the same problem that the camera does not follow the eye position with the animations. I can crouch and prone and see in third person it has succeeded but first person the camera stays the same height and the weapon models disapear unless i look down.Turning renderFirstPerson = true showed something interesting. It seams when i crouch and look down, i see the feet tuck up but the player remains in position, prone appears as if the client is standing.
What the heck!? Anyone have any ideas what is wrong?
#118
enum {
// *** WARNING ***
// These enum values are used to index the ActionAnimationList
// array instantiated in player.cc
// The first five are selected in the move state based on velocity
RootAnim,
RunForwardAnim,
BackBackwardAnim,
SideLeftAnim,
FallAnim,
// These are set explicitly based on player actions
JumpAnim,
StandJumpAnim,
LandAnim,
CrouchRootAnim,
CrouchForwardAnim,
CrawlRootAnim,
CrawlForwardAnim,
SwimRootAnim,
SwimAnim,
//
NumMoveActionAnims = SideLeftAnim + 1,
NumTableActionAnims = SwimAnim + 1,
NumExtraActionAnims = 512,
NumActionAnims = NumTableActionAnims + NumExtraActionAnims,
ActionAnimBits = 14,
NullAnimation = (1 << ActionAnimBits) - 1
};
and In player.cc at around line 118-9 change to this routine...
// Action Animations:
PlayerData::ActionAnimationDef PlayerData::ActionAnimationList[NumTableActionAnims] =
{
// *** WARNING ***
// This array is indexed using the enum values defined in player.h
// Root is the default animation
{ "root" }, // RootAnim,
// These are selected in the move state based on velocity
{ "run", { 0,+1,0 } }, // RunForwardAnim,
{ "back", { 0,-1,0 } }, // BackBackwardAnim
{ "side", { -1,0,0 } }, // SideLeftAnim,
{ "fall" }, // FallAnim
// These are set explicitly based on player actions
{ "jump" }, // JumpAnim
{ "standjump" }, // StandJumpAnim
{ "land" }, // LandAnim
//new animations
{ "crouchroot" },
{ "crouchforward" },
{ "crawlroot" },
{ "crawlforward" },
{ "swimroot" },
{ "swim" }
};
02/28/2007 (6:45 pm)
to this code work and animating correctly, i need to change In player.h at around line 134 change to this routine...enum {
// *** WARNING ***
// These enum values are used to index the ActionAnimationList
// array instantiated in player.cc
// The first five are selected in the move state based on velocity
RootAnim,
RunForwardAnim,
BackBackwardAnim,
SideLeftAnim,
FallAnim,
// These are set explicitly based on player actions
JumpAnim,
StandJumpAnim,
LandAnim,
CrouchRootAnim,
CrouchForwardAnim,
CrawlRootAnim,
CrawlForwardAnim,
SwimRootAnim,
SwimAnim,
//
NumMoveActionAnims = SideLeftAnim + 1,
NumTableActionAnims = SwimAnim + 1,
NumExtraActionAnims = 512,
NumActionAnims = NumTableActionAnims + NumExtraActionAnims,
ActionAnimBits = 14,
NullAnimation = (1 << ActionAnimBits) - 1
};
and In player.cc at around line 118-9 change to this routine...
// Action Animations:
PlayerData::ActionAnimationDef PlayerData::ActionAnimationList[NumTableActionAnims] =
{
// *** WARNING ***
// This array is indexed using the enum values defined in player.h
// Root is the default animation
{ "root" }, // RootAnim,
// These are selected in the move state based on velocity
{ "run", { 0,+1,0 } }, // RunForwardAnim,
{ "back", { 0,-1,0 } }, // BackBackwardAnim
{ "side", { -1,0,0 } }, // SideLeftAnim,
{ "fall" }, // FallAnim
// These are set explicitly based on player actions
{ "jump" }, // JumpAnim
{ "standjump" }, // StandJumpAnim
{ "land" }, // LandAnim
//new animations
{ "crouchroot" },
{ "crouchforward" },
{ "crawlroot" },
{ "crawlforward" },
{ "swimroot" },
{ "swim" }
};
#119
--------------------Configuration: Torque Demo - Win32 Debug--------------------
Compiling...
player.cc
C:\TORQUE\SDK\engine\game\player.cc(3986) : error C4716: 'cPlayersetPlayerPosition' : must return a value
Error executing cl.exe.
I am no programmer, so i'd like to know what i have to change to make it work... any help's welcome, thanks.
Oh, almost forgot: i'm also using Torque Lightining System with the new versio, does that have any influence in the animations code? Thanks again.
--------------------------------------------------------------------------------------------------------------------------------
Oh, this thread is so long that i didn't notice: BERSERK just fixed the problem upthere... sorry!
You fix doing this...
ConsoleMethod( Player, setPlayerPosition, void, 3, 3, "(1=stand, 2=crouch, 3=crawl)")
{
object->setPlayerPosition(dAtof(argv[2]));
}
... we should update the fixes on this resource.
04/02/2007 (6:41 pm)
I'm trying to implement this resource in the brand new 1.5 engine as one of the "ESSENCIAL MODS" for making torque finally usefull, and i'm getting the following error on the compiler:--------------------Configuration: Torque Demo - Win32 Debug--------------------
Compiling...
player.cc
C:\TORQUE\SDK\engine\game\player.cc(3986) : error C4716: 'cPlayersetPlayerPosition' : must return a value
Error executing cl.exe.
I am no programmer, so i'd like to know what i have to change to make it work... any help's welcome, thanks.
Oh, almost forgot: i'm also using Torque Lightining System with the new versio, does that have any influence in the animations code? Thanks again.
--------------------------------------------------------------------------------------------------------------------------------
Oh, this thread is so long that i didn't notice: BERSERK just fixed the problem upthere... sorry!
You fix doing this...
ConsoleMethod( Player, setPlayerPosition, void, 3, 3, "(1=stand, 2=crouch, 3=crawl)")
{
object->setPlayerPosition(dAtof(argv[2]));
}
... we should update the fixes on this resource.
#120
Let's see how to FIX that.
04/03/2007 (7:53 am)
O-kay... now the engine crashes right on the begginig:Fatal:(c:\torque\sdk\sim\sceneobject.cc @ 607) Bad object box!
Let's see how to FIX that.

Torque Owner CIMO
Object (1924) Player -> ShapeBase -> GameBase -> SceneObject -> NetObject -> SimObject"
I have this problem....and my player don't change a position...WHY?
THANKS for help =)