[Help] Set BoneScale

  • Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

forrestmark9

FNG / Fresh Meat
Nov 29, 2011
1,110
40
0
I've been trying to figure this out but how do I change the bonescale of a actor spawned by the PlayerController and is owned by the pawn? So far I can only change it's bonescale by changing the owning pawns bonescale
 

poosh

Grizzled Veteran
Jan 6, 2011
3,403
327
83
As far as I know, it doesn't matter who owns the actor. You should be able to change bone scale anyway. Unless it is an attachment bone and you are trying to set it to 0.
Post the code so I can take a loot at it.
 

forrestmark9

FNG / Fresh Meat
Nov 29, 2011
1,110
40
0
As far as I know, it doesn't matter who owns the actor. You should be able to change bone scale anyway. Unless it is an attachment bone and you are trying to set it to 0.
Post the code so I can take a loot at it.

Here you go

FMXHumanPawn.uc
Code:
simulated function Setup(xUtil.PlayerRecord rec, optional bool bLoadNow)
{
    local KFPlayerReplicationInfo KFPRI;
    
    KFPRI = KFPlayerReplicationInfo(PlayerReplicationInfo);

    Super.Setup(Rec, bLoadNow);
    
    if( KFPRI != none && KFPRI.ClientVeteranSkill != none && KFPRI.ClientVeteranSkillLevel == 50 )
        SpawnHandEmitters();
        
    bHasFootAdjust = False;
    FeetAdjSpec = Class<SPECIES_KFMaleHuman>(rec.Species);
    
    if( Controller == none )
        return;
    else if( FeetAdjSpec==None || Level.NetMode==NM_DedicatedServer || Bot(Controller) != None )
        return;
        
    if( Adjuster!=None )
        Adjuster.Destroy();
        
    Adjuster = Controller.Spawn(class'FPActor', self,, Location, Rotation);
    Adjuster.AdjustingPawn = Self;
    Adjuster.SpecType = FeetAdjSpec;
    Adjuster.LinkMesh(Mesh);
    FPActor(Adjuster).InitAdjuster(rec.BodySkinName, rec.FaceSkinName);
}
FPActor.uc
Code:
class FPActor extends KFPawnFootAdjuster;

var int BodyLoc, CrouchLoc;
var Controller PawnController;

simulated function InitAdjuster(string BodySkin, string FaceSkin)
{
    if( AdjustingPawn.Controller == none)
        return;
        
    LinkMesh(AdjustingPawn.Mesh);
    
    Skins[0] = Material(DynamicLoadObject(BodySkin, class'Material', true));
    Skins[1] = Material(DynamicLoadObject(FaceSkin, class'Material', true));
    
    PawnController = AdjustingPawn.Controller;

    AdjustingPawn.SetBoneScale(1, 0.001, 'CHR_LArmUpper');
    AdjustingPawn.SetBoneScale(2, 0.001, 'CHR_RArmUpper');
    AdjustingPawn.SetBoneScale(4, 0.001, 'CHR_Head');
}

simulated function AdjustBones(bool bSetBoneSize)
{
    if( !bSetBoneSize )
    {
        bHidden = false;
        AdjustingPawn.SetBoneScale(1, 0.001, 'CHR_LArmUpper');
        AdjustingPawn.SetBoneScale(2, 0.001, 'CHR_RArmUpper');
        AdjustingPawn.SetBoneScale(4, 0.001, 'CHR_Head');
    }
    else
    {
        bHidden = true;
        AdjustingPawn.SetBoneScale(1, 1.0, 'CHR_LArmUpper');
        AdjustingPawn.SetBoneScale(2, 1.0, 'CHR_RArmUpper');
        AdjustingPawn.SetBoneScale(4, 1.0, 'CHR_Head');
    }
}

simulated function Tick(float DeltaTime)
{
    local Vector PawnRotation,DrawOffset;
    local bool BoneReset,bBehindViewToggled,bGottenAdjuster;
    local FMXHumanPawn FHumanPawn;

    Super.Tick(DeltaTime);

    if(PawnController == none)
        return;
        
    FHumanPawn = FMXHumanPawn(AdjustingPawn);

    PawnRotation = vector(AdjustingPawn.Rotation);
    PawnRotation.Z = 0.00;
    DrawOffset.Z += AdjustingPawn.EyeHeight-47;

    if( AdjustingPawn != none )
    {
        if( PlayerController(PawnController).bDuck == 1 )
        {
            PawnRotation = float(CrouchLoc) * Normal(PawnRotation);
            SetLocation(AdjustingPawn.Location + PawnRotation + vect(1.35,0,29.5));
        }
        if( PlayerController(PawnController).bDuck == 0 )
        {
            PawnRotation = float(BodyLoc) * Normal(PawnRotation);
            SetLocation(AdjustingPawn.Location + PawnRotation + vect(0.41,0,6.5));
        }
        SetRotation(AdjustingPawn.Rotation);
    }
    
    if(PawnController != none && !PlayerController(PawnController).bBehindView)
        AdjustingPawn.SetTwistLook(FHumanPawn.PawnTwist, 0);
    
    if(!PlayerController(PawnController).bBehindView && bBehindViewToggled)
    {
        bBehindViewToggled = false;
        AdjustBones(false);
        bHidden = false;
    }
    else if(PlayerController(PawnController).bBehindView && !bBehindViewToggled)
    {
        bBehindViewToggled = true;
        AdjustBones(true);
        bHidden = true;
    }
        
    if( (PawnController.IsInState('PlayerFlying') || PawnController.Pawn.Physics == PHYS_Swimming) && !BoneReset )
    {
        BoneReset = true;
        AdjustBones(true);
        bHidden = true;
    }
    else if( (PawnController.IsInState('PlayerWalking') || PawnController.Pawn.Physics == PHYS_Walking) && !bBehindViewToggled )
    {
        BoneReset = false;
        AdjustBones(false);
        bHidden = false;
    }
}

Auto state Setup
{
Begin:
    AdjustingPawn.bHasFootAdjust = True;
    Stop;
}

defaultproperties
{
     BodyLoc=-21
     CrouchLoc=-23
     bHidden=False
     bOnlyOwnerSee=True
     bOnlyRelevantToOwner=True
     bAnimByOwner=True
     bClientAnim=True
     RemoteRole=ROLE_SimulatedProxy
}
 
Last edited:

poosh

Grizzled Veteran
Jan 6, 2011
3,403
327
83
I see a lot of replication issues in your code.

1. Why are you using PawnController.Pawn instead of AdjustingPawn? Controller is replicated only to net owners. If pawn isn't controlled locally, then Controller=none.

2. KFPawnFootAdjuster is spawned locally. Its RemoteRole=ROLE_None. That means no replication for this actior. If you want to replicate it somehow, then you should spawn it on server-side only (spawn it inside non-simulated function or inside Role==ROLE_Authority block) and set RemoteRole=ROLE_SimulatedProxy.

Btw, what are you trying to accomplish with this code?
 

forrestmark9

FNG / Fresh Meat
Nov 29, 2011
1,110
40
0
I see a lot of replication issues in your code.

1. Why are you using PawnController.Pawn instead of AdjustingPawn? Controller is replicated only to net owners. If pawn isn't controlled locally, then Controller=none.

2. KFPawnFootAdjuster is spawned locally. Its RemoteRole=ROLE_None. That means no replication for this actior. If you want to replicate it somehow, then you should spawn it on server-side only (spawn it inside non-simulated function or inside Role==ROLE_Authority block) and set RemoteRole=ROLE_SimulatedProxy.

Btw, what are you trying to accomplish with this code?

This code works to a degree it seems, this code is to spawn first-person legs, it works except for a issue with that I'm required the scale the owning pawns bones in order to scale the bones on the actor, when you walk up stairs or down them the FPActor moves up or down and shows unwanted things, same if you look up and jump

If I use AdjustingPawn then it will scale the bones of every pawn on the map and you will get things such as other players having no arms or legs.

This actor should only be spawned on the client and should only be seen and relevant to it's owner since he is the only person who should be able to see it
 
Last edited: