How to reuse animation blueprint across different characters

Hi Zenity,

This is currently not possible because much of the logic in a given AnimBP is using data linked to a specific (I.E. nodes referencing bones, any kind of IK logic, etc). AnimTrees from UE3 are similar to State Machines, but State Machines are only one component of the larger system that is an Animation Blueprint.

We find that, through iteration, characters with different bone structures that warrant a new tend to have such different animation logic needs (in both the event and animgraph) that it isn’t worth having a Child AnimBP system that spans different skeletons. Due to the significant overhaul this would require and major problems that will most definitely arise from a system like this, it is recommended that different skeletons get their own unique animation blueprints. Hell, we often end up making different AnimBPs for characters using the same because they have different needs logic needs.

Seriously though, I’m glad you’re questioning this. We like to hear this kind of feedback. It’s something I’ve considered in the past, but as you continue to iterate on your characters past the most basic AnimBP logic you’ll find that this is not practical.

-.

1 Like

@.Williams, I don’t actually think it requires any overhaul of the system, or much of an update at all, because I am currently using multiple skeletons on a single Animgraph. I replied with my “hack” to force animgraphs to use multiple skeletons above by duplicating assets and replacing them on delete with assets of new skeletons. This would be one of my highest requested features so I can stop doing this. To have the same logic to exist across animgraphs is a nightmare for development. And retargetting doesn’t even make sense on our project because each character moves so differently, but not enough for their behavior to be scripted differently.

I am now sad this has been resolved. :frowning:

Really, the main problem that I’m seeing is that animation overrides only show assets from the of the original Animgraph (even if the child uses a different ). If you could just show any animation asset regardless of this would be amazing.

Not entirely related to the OP’s issue but this helped me a lot. Thank you for the “As Pin” nudge. This was totally driving me up the wall.

Tags: Reuse, reuse, anim BP, animation blueprint, set animation pragmatically, dynamic animation

that’s not true!
a pig , a dragon, a man, can have different , but each one have stand, run, attack, defend animations.
in animblueprint, they all have same logic: when to run and when to attack!

Hildogen’s pin solution also nudged me in the right direction. We did not want to use retargeting to create duplicate assets for different skeletons that shared the same rig and bone signatures. Our tree logic is quite complex, and in constant iteration so duplicating that logic for multiple skeletons that use the same pattern seemed like an unacceptable workflow risk.

We now have a single AnimBP for multiple pawns using different skeletons. Theoretically, the solution we use might even support different skeletons with completely different bone structures, such as Humans and Puppies.

As erebel55 pointed out, that AnimBP can still only be associated with the same unless you make an engine mod to"USkeletalMeshComponent::NeedToSpawnAnimScriptInstance()". Commenting out the “IsCompatibleMesh()” checks to allow that function to return true for incompatible meshes will let you to make your Puppy pawn/ use the AnimBP created for the Human pawn/.

After that, make sure your AnimBP is your own C++ class that inherits from UAnimInstance, so that you can create your own UPROPERTY(EditDefaultsOnly, BlueprintReadOnly) variables used to feed pins within the AnimBP. So now, your inherited AnimBP has a good set of default variables that make sense for the that it was created from. In order to make your Puppy Pawn use a puppy’s loco blend in the AnimBP instead of the default human’s loco blend, you will need to overwrite the values of those pin-feeding variables in code when the Pawn gets initialized with a set of UPROPERTY(EditDefaultsOnly) variables that live on the Pawn side. We did it inside the scope of our Pawn’s “PreInitializeComponents” override.

I recommend making this variable setting from the pawn optional, letting nullptr on the pawn’s side indicate that it is okay with the default value stored on the AnimBP side.

if (pawn->locoBlend)
{
   animBP->locoBlend = pawn->locoBlend;
}

So setting those properties on the pawn side will ensure that pins get fed with Puppy Sequences/Blends and not Human Sequences/Blends, otherwise, it’ll leave the animBP’s defaults alone.

2 Likes

hello, Kain Shin ~
i’m very interisted in your solution, could you give some more details on how to archive that? you can see my need in above post, that’s so common but not valid in UE4…

Hi wellbye, I am not sure what you mean by ‘archive’, but I’ll post what I can. Much of what I did is in our own game that has not been announced yet, and so I am obligated to leave out details on the gameplay side.

The engine mode is this:

bool USkeletalMeshComponent::NeedToSpawnAnimScriptInstance() const
{
	IAnimClassInterface* AnimClassInterface = IAnimClassInterface::GetFromClass(AnimClass);
	const USkeleton* AnimSkeleton = (AnimClassInterface) ? AnimClassInterface->GetTargetSkeleton() : nullptr;
	//QTN_ENGINE_MOD [Kain: November 3rd, 2016] Allow incompatible meshes to be assigned to enable the use of same AnimGraph with completely different Pawns
	//if (AnimationMode == EAnimationMode::AnimationBlueprint && (AnimSkeleton != nullptr) &&
	//	(SkeletalMesh != nullptr) && (SkeletalMesh->->IsCompatible(AnimSkeleton)
	//		&& AnimSkeleton->IsCompatibleMesh(SkeletalMesh)))
	if (AnimationMode == EAnimationMode::AnimationBlueprint && (AnimSkeleton != nullptr) && (SkeletalMesh != nullptr))
	//...QTN_ENGINE_MOD [Kain: November 3rd, 2016]
	{
		if ( (AnimScriptInstance == NULL) || (AnimScriptInstance->GetClass() != AnimClass) )
		{
			return true;
		}
	}

	return false;
}

An example of a pin feeder is this:

Inside...
class MYGAME_API UMyAnimInstance : public UAnimInstance
	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
		class UBlendSpace* LocoBlend;

Inside...
class MYGAME_API AMyPawn : public ACharacter
	UPROPERTY(EditDefaultsOnly)
		class UBlendSpace* LocoBlend;

You will still need to do the manual hookups of properties to pins in the AnimBP asset. Any node in the AnimBP can have its anim asset exposed as an input pin instead of specified by the node via that “(As pin)” checkbox

Good luck with your PigDragonMan!

1 Like

sorry for my pool words, i was meaning “achieve”.
thanks for your reply~ i have understood your direction,
before try it myself, may i get an answer of:
with this solution, could all anim sequence’s notifies be processed in the same AnimBP?

Yes, notifies come purely from the anim sequence or montage. They do not come from the AnimBP’s graph, so it will be up to you to make sure that your PigDragonMan’s anim sequence or montage contains the proper notify in it if it is different from the default (ManBearPig) 's anim sequence or montage fed into the pin within the AnimBP’s graph node.

I forgot to mention, As I was doing this, I noticed that AimOffset nodes did not handle exposed pins properly. I posted a fix for that here:

1 Like

So was trying this method of swapping your Target in a child AnimBP in UE5, however my character exploded. Speaking with UDN, I was given this response.
“The intended solution for this in UE5 would be the template anim blueprints that we added. They’re agnostic so allow you to setup your graph and then derive from it as a child blueprint at which point you can specify the you want to use.”

4 Likes

It was at least possible in UE4 to create a duplicate animation blueprint with a click and only choose which animations to switch. This would create an animation blueprint with appropriate blendspaces automatically.
It seems that in UE5 this option is gone as well. The fact that this option is gone in UE5 is extremely harmful to our process. Does anyone have any information if there is another solution or a way to do this?

See my post also Options for retargeting animation blueprint is gone in UE5? (no answer there either yet unfortunately)