Seeking Feedback on Door Animation - Code Examples Included

Hello everyone,

I’m currently working on a project in Unreal Engine 5 and am looking for some guidance on implementing a door animation.
To achieve this, I’ve written some code, but I’d like to get your opinions on whether there are more efficient or effective methods. Below, I’ve shared snippets of my code. The first is from my header file and the second is the detailed OnUsed() function.

class MARCOGAME_API ADoor : public AUsablePawn
{
	GENERATED_BODY()
public:
	ADoor();
	void OnUsed() override;
	UPROPERTY(EditInstanceOnly, BlueprintReadWrite)
	USkeletalMeshComponent* SkeletalMesh;
	
	UPROPERTY(EditInstanceOnly, BlueprintReadWrite)
	bool IsOpen = true;
	
	UPROPERTY(EditInstanceOnly, BlueprintReadWrite)
	UAnimationAsset* OpenAnim;
	UPROPERTY(EditInstanceOnly, BlueprintReadWrite)
	UAnimationAsset* ClosingAnim;
};
void ADoor::OnUsed()
{
	if(IsOpen)
	{
		SkeletalMesh->PlayAnimation(ClosingAnim, false);
	}
	else
	{
		SkeletalMesh->PlayAnimation(OpenAnim, false);
	}
	IsOpen = !IsOpen;
}

I would appreciate any feedback, especially regarding the optimization of the animation sequence and integration within UE5. Are there better approaches or practices I should consider? Additionally, if you have any resources or tutorials that could help, I’d be grateful for the recommendations.