crackhead
Newbie
- Joined
- Nov 25, 2004
- Messages
- 2,148
- Reaction score
- 0
hi,
ive recently implimented a 3rd person code but i have a few strange errors. any help or advice would be greatly appreciated.
http://img363.imageshack.us/img363/2263/gunproblem6ec.jpg
the first problem is that some of the weapons dont have any animations for them. i have used the crossbow as an example but its mainly the grenade and crowbar that im concerned about. the crowbar has an idle and run animation but no attack animation. ive used the act_ACT_RANGE_ATTACK1.
is theres something different for crobar and grenades?
http://img363.imageshack.us/img363/23/draged0hj.jpg
another problem im having is that when your shooting and running it only plays the stationary shooting code and just drags the player along.
http://img137.imageshack.us/img137/7793/jumped7ye.jpg
and lastly when you jump whilst stationary it plays the crouch animation mid air.
now then here is the code i used it is from the hl2dm but has been edited to use singleplayer animations which would explain why some things are a bit screwed up.
ive recently implimented a 3rd person code but i have a few strange errors. any help or advice would be greatly appreciated.
http://img363.imageshack.us/img363/2263/gunproblem6ec.jpg
the first problem is that some of the weapons dont have any animations for them. i have used the crossbow as an example but its mainly the grenade and crowbar that im concerned about. the crowbar has an idle and run animation but no attack animation. ive used the act_ACT_RANGE_ATTACK1.
is theres something different for crobar and grenades?
http://img363.imageshack.us/img363/23/draged0hj.jpg
another problem im having is that when your shooting and running it only plays the stationary shooting code and just drags the player along.
http://img137.imageshack.us/img137/7793/jumped7ye.jpg
and lastly when you jump whilst stationary it plays the crouch animation mid air.
now then here is the code i used it is from the hl2dm but has been edited to use singleplayer animations which would explain why some things are a bit screwed up.
Code:
void CHL2_Player::SetAnimation( PLAYER_ANIM playerAnim )
{
int animDesired;
float speed;
speed = GetAbsVelocity().Length2D();
if ( GetFlags() & ( FL_FROZEN | FL_ATCONTROLS ) )
{
speed = 0;
playerAnim = PLAYER_IDLE;
}
Activity idealActivity = ACT_RUN;
// This could stand to be redone. Why is playerAnim abstracted from activity? (sjb)
if ( playerAnim == PLAYER_JUMP )
{
idealActivity = ACT_JUMP;
}
else if ( playerAnim == PLAYER_DIE )
{
if ( m_lifeState == LIFE_ALIVE )
{
return;
}
}
else if ( playerAnim == PLAYER_ATTACK1 )
{
if ( GetActivity( ) == ACT_HOVER ||
GetActivity( ) == ACT_SWIM ||
GetActivity( ) == ACT_HOP ||
GetActivity( ) == ACT_LEAP ||
GetActivity( ) == ACT_DIESIMPLE )
{
idealActivity = GetActivity( );
}
else
{
idealActivity = ACT_RANGE_ATTACK1;
}
}
else if ( playerAnim == PLAYER_RELOAD )
{
idealActivity = ACT_RELOAD;
}
else if ( playerAnim == PLAYER_IDLE || playerAnim == PLAYER_WALK )
{
if ( !( GetFlags() & FL_ONGROUND ) && GetActivity( ) == ACT_JUMP ) // Still jumping
{
idealActivity = GetActivity( );
}
/*
else if ( GetWaterLevel() > 1 )
{
if ( speed == 0 )
idealActivity = ACT_HOVER;
else
idealActivity = ACT_SWIM;
}
*/
else
{
if ( GetFlags() & FL_DUCKING )
{
if ( speed > 0 )
{
idealActivity = ACT_WALK_CROUCH;
}
else
{
idealActivity = ACT_COVER_LOW; //ACT_IDLE_CROUCH;
}
}
else
{
if ( speed > 0 )
{
idealActivity = m_fIsSprinting ? ACT_WALK : ACT_RUN;
}
else
{
idealActivity = ACT_IDLE;
}
}
}
//idealActivity = TranslateTeamActivity( idealActivity );
}
if ( idealActivity == ACT_RANGE_ATTACK1 )
{
RestartGesture( Weapon_TranslateActivity( idealActivity ) );
// FIXME: this seems a bit wacked
Weapon_SetActivity( Weapon_TranslateActivity( ACT_RANGE_ATTACK1 ), 0 );
return;
}
else if ( idealActivity == ACT_RELOAD )
{
RestartGesture( Weapon_TranslateActivity( idealActivity ) );
return;
}
else
{
SetActivity( idealActivity );
animDesired = SelectWeightedSequence( Weapon_TranslateActivity ( idealActivity ) );
if (animDesired == -1)
{
animDesired = SelectWeightedSequence( idealActivity );
if ( animDesired == -1 )
{
animDesired = 0;
}
}
// Already using the desired animation?
if ( GetSequence() == animDesired )
return;
m_flPlaybackRate = 1.0;
ResetSequence( animDesired );
SetCycle( 0 );
return;
}
// Already using the desired animation?
if ( GetSequence() == animDesired )
return;
//Msg( "Set animation to %d\n", animDesired );
// Reset to first frame of desired animation
ResetSequence( animDesired );
SetCycle( 0 );
}