UE3 - UDK Swap Modular Pawn Components on Runtime

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Pixar

New Member
Feb 6, 2014
1
0
0
Hello everyone,

I've successfully created a custom modular pawn and made it the player character. It's working fine, the animations from my custom animtree are working as expected, yet I'm unable to change the modular pawn's skeletal mesh components during the game.

I've searched everywhere, but so far no solution works.

My custom Player Controller class is this:

Code:
class JTPlayerController extends UTPlayerController
 config(JTGame);

exec function MudarModuloTorso()
{

    JTPawn(Pawn).TorsoSkeletalMesh.SetSkeletalMesh(SkeletalMesh'MyPackage.modulotroncoM');
}

exec function MudarModuloPernas()
{

    JTPawn(Pawn).LegsSkeletalMesh.SetSkeletalMesh(SkeletalMesh'MyPackage.modulopernasM');
}
 
defaultproperties
{
    bBehindView=true;
    bForceBehindView=true;
}

(Note: the exec functions are binded to the keys "I" and "O". These functions seem to be called, as they appear in the log files. And yes, there is a package called MyPackage with modulopernasM and modulotroncoM meshes there.)

My custom Pawn class is this:

Code:
class JTPawn extends UTPawn placeable;

// Skeletal mesh which represents the head. Parent skeletal mesh component.
var(PersonaModular) const SkeletalMeshComponent HeadSkeletalMesh;
// Skeletal mesh which represents the upper body. Child to the head skeletal mesh component.
var(PersonaModular) const SkeletalMeshComponent TorsoSkeletalMesh;
// Skeletal mesh which represents the lower body. Child to the head skeletal mesh component.
var(PersonaModular) const SkeletalMeshComponent LegsSkeletalMesh;

defaultproperties
{
    Begin Object Name=MyLightEnvironment
        bSynthesizeSHLight=TRUE
        bIsCharacterLightEnvironment=TRUE
    End Object

    Components.Add(MyLightEnvironment)

    LightEnvironment=MyLightEnvironment

    // Remove UTPawn's defined skeletal mesh
  Components.Remove(WPawnSkeletalMeshComponent)


  // Create the head skeletal mesh component
  Begin Object Class=SkeletalMeshComponent Name=HeadSkeletalMeshComponent
        SkeletalMesh=SkeletalMesh'MyPackage.modulocabeca';
        AnimTreeTemplate=AnimTree'MyPackage.funcoesani1';
        AnimSets(0)=AnimSet'MyPackage.anitestes1';
        LightEnvironment=MyLightEnvironment;
    bCacheAnimSequenceNodes=false
    AlwaysLoadOnClient=true
    AlwaysLoadOnServer=true
    bOwnerNoSee=true
    CastShadow=true
    BlockRigidBody=true
    bUpdateSkelWhenNotRendered=false
    bIgnoreControllersWhenNotRendered=true
    bUpdateKinematicBonesFromAnimation=true
    bCastDynamicShadow=true
    RBChannel=RBCC_Untitled3
    RBCollideWithChannels=(Untitled3=true)
    bOverrideAttachmentOwnerVisibility=true
    bAcceptsDynamicDecals=false
    bHasPhysicsAssetInstance=true
    TickGroup=TG_PreAsyncWork
    MinDistFactorForKinematicUpdate=0.2
    bChartDistanceFactor=true
    RBDominanceGroup=20
    bUseOnePassLightingOnTranslucency=true
    bPerBoneMotionBlur=true
  End Object
  HeadSkeletalMesh=HeadSkeletalMeshComponent
  Components.Add(HeadSkeletalMeshComponent)
  Mesh=HeadSkeletalMeshComponent

  // Create the upper body skeletal mesh component
  Begin Object Class=SkeletalMeshComponent Name=TorsoSkeletalMeshComponent
    SkeletalMesh=SkeletalMesh'MyPackage.modulotronco'
    bCacheAnimSequenceNodes=false
    AlwaysLoadOnClient=true
    AlwaysLoadOnServer=true
    bOwnerNoSee=true
    CastShadow=true
    BlockRigidBody=true
    bUpdateSkelWhenNotRendered=false
    bIgnoreControllersWhenNotRendered=true
    bUpdateKinematicBonesFromAnimation=true
    bCastDynamicShadow=true
    RBChannel=RBCC_Untitled3
    RBCollideWithChannels=(Untitled3=true)
    LightEnvironment=MyLightEnvironment
    bOverrideAttachmentOwnerVisibility=true
    bAcceptsDynamicDecals=false
    bHasPhysicsAssetInstance=true
    TickGroup=TG_PreAsyncWork
    MinDistFactorForKinematicUpdate=0.2
    bChartDistanceFactor=true
    RBDominanceGroup=20
    bUseOnePassLightingOnTranslucency=true
    bPerBoneMotionBlur=true
    // Assign the parent animation component to the head skeletal mesh component. This ensures that
    // the pawn animates as if it was one skeletal mesh component.
    ParentAnimComponent=HeadSkeletalMeshComponent
    // Assign the shadow parent component to the head skeletal mesh component. This is used to speed up
    // the rendering of the shadow for this pawn and to prevent shadow overlaps from occur.
    ShadowParent=HeadSkeletalMeshComponent
  End Object
  TorsoSkeletalMesh=TorsoSkeletalMeshComponent
  Components.Add(TorsoSkeletalMeshComponent)

  // Create the lower body skeletal mesh component
  Begin Object Class=SkeletalMeshComponent Name=LegsSkeletalMeshComponent
    SkeletalMesh=SkeletalMesh'MyPackage.modulopernas'
    bCacheAnimSequenceNodes=false
    AlwaysLoadOnClient=true
    AlwaysLoadOnServer=true
    bOwnerNoSee=true
    CastShadow=true
    BlockRigidBody=true
    bUpdateSkelWhenNotRendered=false
    bIgnoreControllersWhenNotRendered=true
    bUpdateKinematicBonesFromAnimation=true
    bCastDynamicShadow=true
    RBChannel=RBCC_Untitled3
    RBCollideWithChannels=(Untitled3=true)
    LightEnvironment=MyLightEnvironment
    bOverrideAttachmentOwnerVisibility=true
    bAcceptsDynamicDecals=false
    bHasPhysicsAssetInstance=true
    TickGroup=TG_PreAsyncWork
    MinDistFactorForKinematicUpdate=0.2
    bChartDistanceFactor=true
    RBDominanceGroup=20
    bUseOnePassLightingOnTranslucency=true
    bPerBoneMotionBlur=true
    // Assign the parent animation component to the head skeletal mesh component. This ensures that
    // the pawn animates as if it was one skeletal mesh component.
    ParentAnimComponent=HeadSkeletalMeshComponent
    // Assign the shadow parent component to the head skeletal mesh component. This is used to speed up
    // the rendering of the shadow for this pawn and to prevent shadow overlaps from occur.
    ShadowParent=HeadSkeletalMeshComponent
  End Object
  LegsSkeletalMesh=LegsSkeletalMeshComponent
  Components.Add(LegsSkeletalMeshComponent)
}

(Note:I've already tried turning those three skeletal meshes vars into non-constants, but the issue remains. By the way, I also tried making custom functions inside this custom pawn class to change the meshes and then have the custom playercontroller class call those functions instead of directly setting the skeletalmeshes, however nothing happened.)

Does anyone has any ideias on why I'm unable to change the modular pawn's skeletalmeshes during the game? Is there anything wrong with my code or did I forgot to do something?
 
Aug 24, 2015
2
0
1
33
Hello man, sorry for answering after such a long time, but, i'm also making a game with UDK, and i'm having quite a hard time getting it to do what i want, however, i did make some modular pawn (the wrong way) that kinda works, my pawn class is as follows:


Code:
class MyPawn extends UDKPawn placeable;

var(ModularPawn) const SkeletalMeshComponent HeadSkeletalMesh;
var(ModularPawn) const SkeletalMeshComponent TorsoSkeletalMesh;

defaultproperties
{
        Components.Remove(Sprite)
    //Setting up the light environment
    Begin Object Class=DynamicLightEnvironmentComponent Name=MyLightEnvironment
        ModShadowFadeoutTime=0.25
        MinTimeBetweenFullUpdates=0.2
        AmbientGlow=(R=0,G=0,B=0,A=0)
        AmbientShadowColor=(R=0.15,G=0.15,B=0.15)
        bSynthesizeSHLight=TRUE
    End Object
    Components.Add(MyLightEnvironment)
  
    //Setting up the mesh and animset components
    Begin Object Class=SkeletalMeshComponent Name=HeadSkeletalMesh
        CastShadow=true
        bCastDynamicShadow=true
        bOwnerNoSee=false
        LightEnvironment=MyLightEnvironment;
        BlockActors=true
        BlockRigidBody=true;
        CollideActors=true;
        BlockZeroExtent=true;
        //What to change if you'd like to use your own meshes and animations
        PhysicsAsset=PhysicsAsset'PlayerCharacter.Characters.PlayerPhysics'
        AnimSets(0)=AnimSet'PlayerCharacter.Characters.PlayerAnims'
        AnimTreeTemplate=AnimTree'PlayerCharacter.Characters.PlayerAnimTree'
        SkeletalMesh=SkeletalMesh'PlayerCharacter.Characters.NewWomanHead'
    End Object

    Begin Object Class=SkeletalMeshComponent Name=TorsoSkeletalMesh
        CastShadow=true
        bCastDynamicShadow=true
        bOwnerNoSee=false
        LightEnvironment=MyLightEnvironment;
        BlockActors=true
        BlockRigidBody=true;
        CollideActors=true;
        BlockZeroExtent=true;
        //What to change if you'd like to use your own meshes and animations
        PhysicsAsset=PhysicsAsset'PlayerCharacter.Characters.PlayerPhysics'
        AnimSets(0)=AnimSet'PlayerCharacter.Characters.PlayerAnims'
        AnimTreeTemplate=AnimTree'PlayerCharacter.Characters.PlayerAnimTree'
        SkeletalMesh=SkeletalMesh'PlayerCharacter.Characters.NewWomanTorso'
    End Object
  
    //Setting up a proper collision cylinder
    Mesh=HeadSkeletalMesh;
    Components.Add(HeadSkeletalMesh);
    Components.Add(TorsoSkeletalMesh);
    CollisionType=COLLIDE_BlockAll
    Begin Object Name=CollisionCylinder
    CollisionRadius=+0023.000000
    CollisionHeight=+0000.000000
    End Object
    CylinderComponent=CollisionCylinder

    Buoyancy=+000.99000000
}
simulated function name GetDefaultCameraMode(PlayerController RequestedBy)
{
    return 'FreeCam_Default';
}

I have here only the head and torso, just for testing.
And to change the SkeletalMesh of any bodypart i'm thinking of creating a function inside each bodypart Object that would call any mesh desired and replace the line "SkeletalMesh=SkeletalMesh'PlayerCharacter.Characters.NewWomanTorso'", for instance.

I'm really sad that we get so little support when doubts like these show up, people just don't bother.

We have to unite all the newbs and make an active community.