Hi!
I’m trying to implement this piece of code from Rotate Actor Around player:
#include "RotateActorAroundPlayer.h"
// Sets default values
ARotateActorAroundPlayer::ARotateActorAroundPlayer()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
Dimensions = FVector (300, 0, 0);
AxisVector = FVector (0, 0, 1);
Multiplier = 50.f;
}
// Called when the game starts or when spawned
void ARotateActorAroundPlayer::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void ARotateActorAroundPlayer::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
FVector NewLocation = GetWorld()->GetFirstPlayerController()->GetPawn()->GetActorLocation();
AngleAxis += DeltaTime * Multiplier;
if(AngleAxis >= 360.0f)
{
AngleAxis = 0;
}
FVector myCharacter = GetWorld()->GetFirstPlayerController()->GetPawn()->GetActorLocation();
FVector RotateValue = Dimensions.RotateAngleAxis(AngleAxis, AxisVector);
NewLocation.X += RotateValue.X;
NewLocation.Y += RotateValue.Y;
NewLocation.Z += RotateValue.Z;
SetActorLocation(NewLocation, false, 0, ETeleportType::None);
}
In blueprints:
The object moves around the player but it doesn’t rotate. I don’t know what I’ve made wrong. Probably the Bluescript function RotateVectorAroundAxis is not the same function for RotateAngleAxis in C++.
I have used the same values for Dimensions, AxisVector and Multiplier.
What have I done wrong?
Update:
I have tested the C++ code and it doesn’t the same: the RotateActorAroundPlayer moves around the player but it doesn’t face to the player all the time.