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"

Interpolating between 2 FVectors, so confused...

I'm calculating a movement vector, where magnitude is used for the velocity in the frame and the units for direction, using various effects like input, gravity etc (doing it from scratch in Pawn).

I'm stuck on calculating an FVector that is somewhere between 2 existing FVectors. I have used lerp and such in blueprints, but I know those use rotators. So is that the same process in c++? Do I lerp, having to deconstruct the FVectors into FRotators (I believe this uses unit vectors? maybe a conversion to degrees from there?), average the original FVectors lengths and reapply the magnitude to the result of the lerp (assuming it's a unit vector again)?

Or is there a more direct way to lerp using the FVectors directly?


Product Version: Not Selected
more ▼

asked Apr 24 '15 at 07:08 PM in C++ Programming

avatar image

242 18 27 36

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

1 answer: sort voted first

Im not sure what you're asking but if you want to lerp between 2 Vectors or 2 Rotators this is the simplest way as i know:

 // Lerp Between 2 FVectors
 FVector A;
 FVector B;
 float Alpha = 0.5f;
 FVector C = FMath::Lerp(A, B, Alpha);
 // To Get the Rotation From a Vector

 // Lerp Between 2 FRotators
 FRotator A;
 FRotator B;
 float Alpha = 0.5f;
 FRotator C = FMath::Lerp(A, B, Alpha);

 // To get the vectors from a rotator

By the way everything is identical to the blueprint names so it should be easy to port your bps to c++.

more ▼

answered Apr 24 '15 at 07:15 PM

avatar image

1.9k 61 52 191

avatar image DanaFo Apr 24 '15 at 07:22 PM

Excellent, thank you very much for that!

avatar image Azarus Apr 24 '15 at 07:34 PM

Thanks. :) By the way the answer is now unaccepted because of the comment :P

(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