Download

able to change skeletal mesh but then no animation - just a t pose moving

after I change the skeletal mesh the pawn no longer animates - just goes into TPOSE but moves forward/backward, etc.

I even tried re-issuing the animation blueprint to see if that would re-start the animation… but no

am I missing something?




void AMySpawner::SpawnEnemy()
{
	UWorld* World = GetWorld();

	USkeletalMesh* NewMesh;


	if (World)
	{

		AMyMonster* SpawnedMonster = World->SpawnActor<AMyMonster>(WhatToSpawn, GetActorLocation(), GetActorRotation());


		NewMesh = Cast<USkeletalMesh>(StaticLoadObject(USkeletalMesh::StaticClass(), NULL, TEXT("SkeletalMesh'/Game/Monsters/FuseModel2.FuseModel2'")));

	

	
		SpawnedMonster->GetMesh()->SetSkeletalMesh(NewMesh);





	


//tried adding the code below to see if re-issuing the animation blueprint would get the animation back - but no

		UAnimBlueprint* AnimBP = Cast<UAnimBlueprint>(StaticLoadObject(UAnimBlueprint::StaticClass(), NULL, TEXT("AnimBlueprint'/Game/Monsters/Zombie_animationBP.Zombie_animationBP'")));
		
                if (AnimBP)
		{
			
			SpawnedMonster->GetMesh()->SetAnimInstanceClass(AnimBP->GeneratedClass);

		}
	








		
	}


}




The animation blueprint should be made for the mesh in question. If the skeletons share animations, configure the skeletons of both the old mesh and its replacement with the retargeting configuration. That way, you can copy the animation blueprint for that particular mesh.

You might want to read those: