Hi all,
I’m using the 3rd person c++ template.
What I am trying to do is set up my character so when he runs through a trigger, it changes his direction by 45 degrees and just keeps running in the correct new direction. The whole time you just hold right on the stick. If you can imagine a camera looking at the guy, he eventually will run in a large octagon around the camera, where there are 8 distinct turns to ensure he gets back to his start position.
I have that process setup and working in c++ except after changing his angle, he adjusts back and runs exactly right.
in the Character class, the template has :
void ATheTowerCharacter::MoveRight(float Value)
{
// add movement in that direction
AddMovementInput(FVector(0.f,1.f,0.f), Value);
}
In my overlap function I capture running over the trigger, then change the angle:
void ATheTowerCharacter::OnOverlapBegin(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
//GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Blue, "OverlapEvent: " + OtherActor->GetName());
if ((OtherActor != nullptr) && (OtherActor != this))
{
// cast actor to AngleChangeTrigger
AAngleChangeTrigger* const changeTrigger = Cast<AAngleChangeTrigger>(OtherActor);
if (changeTrigger != nullptr)
{
float direction = this->InputComponent->GetAxisValue("MoveRight");
ChangeAngle(direction);
}
}
}
void ATheTowerCharacter::ChangeAngle(float direction)
{
int multiplayer = FMath::Abs(direction);
FTransform transform = this->GetTransform();
transform.ConcatenateRotation(FRotator(0, direction * 45, 0).Quaternion());
transform.NormalizeRotation();
this->SetActorTransform(transform);
}
I’m unsure at this stage if I am rotating the right object? ‘this’ is the PlayerCharacter class in the template.
Looking at the screen shot, the guy is rotated but his rotation in the transform view does not appear to have any rotation applied?
I expected when the MoveRight method says move right, it is relative to it’s transform, but it does not appear so?
Cheers


