Closed henbagle closed 2 weeks ago
Vegz to the rescue! Code snippet is below.
Class SFXSeqAct_SetMorphHead extends SequenceAction;
var(SFXSeqAct_SetMorphHead) Actor Target;
var(SFXSeqAct_SetMorphHead) BioMorphFace oMorphHead;
public static event function int GetObjClassVersion()
{
return Super(SequenceObject).GetObjClassVersion() + 1;
}
public function Activated()
{
local BioPawn Pawn;
local SkeletalMesh oMesh;
Pawn = BioPawn(Target);
if (Pawn != None)
{
ApplyMesh(oMorphHead.m_oBaseHead, Pawn.m_oHeadMesh);
Pawn.ApplyMaterialParameters(oMorphHead.m_oMaterialOverrides);
Pawn.ForceUpdateComponents();
}
}
private final function ApplyMesh(SkeletalMesh SkelMesh, SkeletalMeshComponent MeshCmpt)
{
local int I;
local Name nmActiveEffectsMaterial;
if (SkelMesh != None && MeshCmpt != None)
{
nmActiveEffectsMaterial = MeshCmpt.GetEffectsMaterial();
MeshCmpt.ClearEffectsMaterial();
MeshCmpt.SetSkeletalMesh(SkelMesh);
for (I = 0; I < SkelMesh.Materials.Length; I++)
{
MeshCmpt.SetMaterial(I, None);
MeshCmpt.CreateAndSetMaterialInstanceConstant(I);
}
if (nmActiveEffectsMaterial != 'None')
{
MeshCmpt.SetEffectsMaterial(nmActiveEffectsMaterial);
}
}
}
We have several cut unique faces for NPCs that could be restored as an option in the settings menu - except the methods for updating an NPC's appearance don't work as well as the methods just updating a material.
As far as I can tell, the UpdatePawnAppearance method can be a little glitchy. the user will see the NPC pop in and out of existence when it occurs, and I've had instances of NPCs falling through the floor. Plus I don't know what would happen if the NPC was midway through a line of dialogue. Is there some way we can develop to instantly update the morph face without triggering this method?