[Sixpack]-Shambler- said:
Ok I've only just started coding stuff in C++ today...Can someone please (for the love of god) tell me how I can convert a vector into a rotator (FVector into FRotator) through C++??
I've looked all the way through UnMath.h and other public source files and I didn't find an answer..
I have only done this thing before when I was only consirended with the yaw and pitch. However you should be able to just add in the z component for the following if you need the roll.
For startes you will need the direction of the vector. This can be found by:
//use atan2 beceause there are cases when atan can return infinity.
//direction will be in radians
direction = atan2(v.y,v.x);
//you will also need the magnitude of the vector
magnitude = sqrt(v.x*v.x + v.y * v.y);
//here is where you would get your x and y componets of your rotator
//i.e your yaw and pitch.
yaw = magnitude * cos(direction);
pitch = magnitude * sin(direction);
Hope this helped