Here is My Code Short & Simple!

//Copyright© 2021 Vishal Ahirwar.

#include "DoorComponent.h"
#include"GameFramework/Actor.h"

UDoorComponent::UDoorComponent()
{
	PrimaryComponentTick.bCanEverTick = true;
}
void UDoorComponent::BeginPlay()
{
	Super::BeginPlay();
	TargetYaw+=GetOwner()->GetActorRotation().Yaw;
}
void UDoorComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
	Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

	FRotator NewRotation =GetOwner()->GetActorRotation();
	NewRotation.Yaw = FMath::FInterpTo(GetOwner()->GetActorRotation().Yaw,TargetYaw,DeltaTime,VSpeed);
	GetOwner()->SetActorRotation(NewRotation);
}


2 Likes

Simple and clean

1 Like

Yeah!
:smiley:

Privacy & Terms