[Update 8pm GMT] UDK: Model's animations aren't playing!

Started by
12 comments, last by Sammieo 11 years ago

Glad to hear that the collision cylinder's aligned now biggrin.png

As for animations, the PlayAnim function takes a name as the first parameter, not an AnimSet (which is what I assume you're trying to call with that line).

If the anim name you want to play is WalkOnLand, then assuming that you have BirdWalkAnim set in the DefaultProperties, you'd use the line:


Pawn.Mesh.PlayAnim( BirdPawn(Pawn).BirdWalkAnim, , True );

There's no need to mess with the file path OR anim set with the PlayAnim function, which will search the SkeletalMeshComponent's AnimSets array to find the correct animation.

Advertisement

Ah, I see! Silly me, I should have caught onto that earlier. Good news, I tried the name var instead and it got past the compiler without a bother.

...Bad news, it's still not working. >_< The lil' birdy is just hovering there, no matter what my anim calls say.

Ho-hum. Lemme show you the code one more time, since this is almost over:



class BirdPawn extends UTPawn;

var int IsoCamAngle;
var float CamOffsetDistance;

//var() SkeletalMeshComponent BirdMesh;
//var() SkeletalMeshComponent CurrMesh;

var name BirdWalkAnim;
var name BirdFlyAnim;

simulated function PostBeginPlay()
{
    super.PostBeginPlay();
    //AttachMesh();
    SetMeshVisibility(true);
    //PlayAnim( self.Boobooday_Packed_FlapWings, , True );
}

simulated function SetCharacterClassFromInfo(class<UTFamilyInfo> Info)
{
    //Ignoring family info
}

simulated function SetMeshVisiblity(bool bVisible)
{
    super.SetMeshVisibility(bVisible);
    Mesh.SetOwnerNoSee(false);
}

simulated function bool CalcCamera(float DeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV)
{
    local Vector HitLocation, HitNormal;

    out_CamLoc           = Location;
    out_CamLoc.X        -= Cos(Rotation.Yaw * UnrRotToRad) * Cos(IsoCamAngle * UnrRotToRad) * CamOffsetDistance;
    out_CamLoc.Y        -= Sin(Rotation.Yaw * UnrRotToRad) * Cos(IsoCamAngle * UnrRotToRad) * CamOffsetDistance;
    out_CamLoc.Z        -= Sin(IsoCamAngle * UnrRotToRad) * CamOffsetDistance;

    out_CamRot.Yaw       = Rotation.Yaw;
    out_CamRot.Pitch     = IsoCamAngle;
    out_CamRot.Roll      = 0;

    if (Trace(HitLocation, HitNormal, out_CamLoc, Location, false, vect(12, 12, 12)) != none)
    {
        out_CamLoc = HitLocation;
    }

    return true;
}

defaultproperties
{
    IsoCamAngle=20
    CamOffsetDistance=190.0
    MaxFallSpeed=30000

    Begin Object Class=AnimNodeSequence Name=MeshSequenceA
    End Object

    /*
    * Begin Object Class=DynamicLightEnvironmentComponent Name=MyLightEnvironment
    *  bEnabled=TRUE
    *  End Object
    * Components.Add(MyLightEnvironment)
    */

    Begin Object Name=WPawnSkeletalMeshComponent
          SkeletalMesh=SkeletalMesh'BirdPackage.Boobooday_Packed'
          AnimSets(0)=AnimSet'BirdPackage.Armature'
          Animations=MeshSequenceA
          AnimTreeTemplate=None
          Translation=(Z=-20.0)
          Materials(0)=Material'EditorMaterials.WidgetMaterial_X'
          LightEnvironment=MyLightEnvironment
          Scale3D=(X=5.00,Y=5.00,Z=5.25)
    End Object

    BirdWalkAnim = WalkOnLand
    BirdFlyAnim = FlapWings
}
 
Controller:

class BirdPlayerController extends UTPlayerController;

var vector PlayerViewOffset;
var bool bHasFood;

simulated function PostBeginPlay()
{
  super.PostBeginPlay();
  bNoCrosshair = true;
  `log("The Bird player controller has finally spawned!");
  GoToState('Walking');

  Pawn.Mesh.SetHidden(false);
}

reliable client function ClientSetHUD(class<HUD> newHUDType)
{
  if(myHUD != none)
           myHUD.Destroy();

  myHUD = spawn(class'BirdHUD', self);
}

auto state Walking extends PlayerWalking
{
  simulated function BeginState(Name PreviousStateName)
  {
    Pawn.SetMovementPhysics();
    `log(GetStateName() );
    `log("Hello, the Bird is now walking!");
    Pawn.Mesh.PlayAnim( BirdPawn(Pawn).BirdWalkAnim, , True );
    //Pawn.Mesh.PlayAnim( BirdPawn(Pawn).Boobooday_Packed_WalkOnLand, , True );
  }
  function ProcessMove(float DeltaTime, vector NewAccel, eDoubleClickDir DoubleClickMove, rotator DeltaRot)
  {
    local vector X, Y, Z;
    //`log(NewAccel);

    GetAxes(Pawn.Rotation, X, Y, Z);
    NewAccel = PlayerInput.aForward * X + PlayerInput.aStrafe*Y;
    NewAccel.Y = 0;
    NewAccel = Pawn.AccelRate * Normal(NewAccel);

    super.ProcessMove(DeltaTime, X * VSize(NewAccel), DoubleClickMove, DeltaRot);
  }
}

state BirdFlying extends PlayerFlying
{
  simulated function BeginState(name PreviousStateName)
  {
    super.BeginState(PreviousStateName);
    Pawn.Mesh.PlayAnim( BirdPawn(Pawn).BirdFlyAnim, , True );
    `log("Now in Flying state!");
  }
}

defaultproperties
{
  bBehindView = true
  PlayerViewOffset = (X=256, Y = 0, Z = 0)
  bHasFood = true
}

If it were one thing, I'd guess it's the AnimNodeSequence object in the DefaultProperties. UTPawn already has two AnimNodeSequences called MeshSequenceA and MeshSequenceB, so trying to overwrite MeshSequenceA might be causing the problem. Try commenting out those two lines in your pawn's DefaultProperties (right above the commented-out DynamicLightEnvironment) and see if that helps.

Failing that, there's always the obligatory "make sure the animation actually works in the editor" advice. :P

Also, I've heard that DefaultProperties doesn't like spaces with declarations, like "BirdWalkAnim = WalkOnLand"... Apparently it's better to write "BirdWalkAnim=WalkOnLand". I've personally never had any problem with it either way, but can't hurt to try, even though it's probably not the source of the problem.

Hope something here works for you :D

Thanks for the clarity there. I tried both, and it didn't quite work out.


Ah well, no big bother. I'm gonna try one kismet video and hope that takes care of things. Fingers crossed!

This topic is closed to new replies.

Advertisement