Wiki Code Tutorials

Animated Vertex Positions With Movement Velocity Correction

Dear Community,

I’ve released a new wiki on how you can obtain animated vertex positions of character meshes!

https://wiki.unrealengine./Animated_Vertex_Positions_How_To_Obtain_Them


**C++ Code For You**

Here's the code I just finished writing to obtain accurate animated character vertex positions!



```


bool UVictoryBPFunctionLibrary::AnimatedVertex__GetAnimatedVertexLocations(
	USkeletalMeshComponent* Mesh, 
	TArray<FVector>& Locations,
	bool PerformPawnVelocityCorrection
){
	if(!Mesh || !Mesh->SkeletalMesh)  
	{
		return false;
	}

	//~~~~~~~~~~~~~
	Locations.Empty(); 
	//~~~~~~~~~~~~~
	 
	Mesh->ComputeSkinnedPositions(Locations);
	
	FTransform ToWorld = Mesh->GetComponentTransform();
	FVector WorldLocation = ToWorld.GetLocation();
	
	//Pawn Velocity Correction
	UPawnMovementComponent* MovementComp = nullptr;
	if(PerformPawnVelocityCorrection)
	{
		APawn* Pawn = Cast<APawn>(Mesh->GetOwner());
		MovementComp = (Pawn) ? Pawn->GetMovementComponent() : NULL;
	}
	bool DoVelocityCorrection = PerformPawnVelocityCorrection && MovementComp;
	//Pawn Velocity Correction
	 
	for(FVector& Each : Locations)
	{
		Each = WorldLocation + ToWorld.TransformVector(Each);
		if(DoVelocityCorrection)
		{
			Each += MovementComp->Velocity * FApp::GetDeltaTime();
		} 
	} 
	
	return true;
}


```



Enjoy!

:)