Set Actor Foward Vector

Wait what? Actor forward vector = Actor Rotation to vector.

1 Like

Hey all,

I was just wondering if there is any way to set the forward vector on an actor? What I’m trying to accomplish is I’m handling input from the joystick (both x and y axii) and I want to set the forward vector to point along that direction so he will rotate with the joystick’s location.

SetActorForwardVector(Vector(.5f, .5f, 0));

If this isn’t possible, can anyone give me an idea of how to do that?

Thanks a bunch.

  • Austin

Not sure how that helps me. Can you go into more detail? I know how to get both the actor rotation and forward direction, I’m asking if there is a way to SET the forward vector.

I didn’t realize you could just call a someVector.Rotation.


Take a look:

FVector AActor::GetActorForwardVector() const
	return GetTransform().GetUnitAxis(EAxis::X);

This code returns X vector from Root Component, when You set

bool AActor::SetActorRotation(FRotator NewRotation)
	if (RootComponent)
		return RootComponent->MoveComponent( FVector::ZeroVector, NewRotation, true );

	return false;

SetActorRotation will update Forward vector axis X too.

And If you want to rotate actor that he will point some direction, you can do something like this:

FVector YourVector;

1 Like