x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Set Actor Foward Vector

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.

example: 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

Product Version: Not Selected
Tags:
more ▼

asked Aug 29 '14 at 05:08 AM in C++ Programming

avatar image

AustinK
215 22 19 28

avatar image Pierdek Aug 29 '14 at 05:27 AM

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

avatar image AustinK Aug 29 '14 at 06:09 AM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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;
 
 SetActorRotation(YourVector.Rotation());
more ▼

answered Aug 29 '14 at 06:38 AM

avatar image

Pierdek
2.6k 73 49 131

avatar image AustinK Aug 29 '14 at 08:13 AM

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

Thanks!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question