我在我的UDK游戏中编写了一个冲刺状态到一个自定义的棋子类中。我在看Epic的管理状态的示例代码,大部分游戏逻辑都在Controller类中,而不是Pawn类中。这对我来说似乎是倒退的。我最初认为控制器只是简单地处理AI和玩家输入,现在我不确定在哪里放置我自己的状态代码。
例如,PlayerController.uc文件有PlayerWalking、PlayerClimbing等,但似乎也改变了兵的状态:
// player is climbing ladder
state PlayerClimbing
{
ignores SeePlayer, HearNoise, Bump;
event NotifyPhysicsVolumeChange( PhysicsVolume NewVolume )
{
if( NewVolume.bWaterVolume )
{
GotoState( Pawn.WaterMovementState );
}
else
{
GotoState( Pawn.LandMovementState );
}
}
...既然冲刺状态应该否定PlayerWalking状态,我应该将冲刺状态代码放在控制器类中而不是兵中吗?应该如何处理这种逻辑?谢谢!
发布于 2012-06-14 01:26:18
PlayerWalking和PlayerClimbing更多的是关于棋子的物理和动画模式,而不是实际的行走和冲刺。
要做到这一点,一种基于状态的简单方法是创建一个从PlayerWalking派生的PlayerSprinting状态,然后在两个状态下,在进入状态时将GroundSpeed设置为您想要的状态。
举个例子:
state PlayerSprinting extends PlayerWalking
{
event BeginState(Name PreviousStateName)
{
//coped from UTPawn
DoubleClickDir = DCLICK_None;
bPressedJump = false;
GroundPitch = 0;
if ( Pawn != None )
{
Pawn.ShouldCrouch(false);
if (Pawn.Physics != PHYS_Falling && Pawn.Physics != PHYS_RigidBody) // FIXME HACK!!!
Pawn.SetPhysics(Pawn.WalkingPhysics);
}
//END UTPawn
//Ground speed modify
GroundSpeed=SprintSpeed;
}
}https://stackoverflow.com/questions/11006334
复制相似问题