• News

• Industries

• Learning & Support

• Community

• Marketplace

# FindLookAtRotation and declaring Up vector?

Is there any way to declare and use a custom Up vector in the FindLookAtRotation function?
Reason i ask, is because it seems the return value always uses the world Z as up. So making games like “f-zero/XGRA” is a nightmare.

Basically, i’am having a break from c++ coding and giving visual blueprints a go, really enjoying it.
Heres my original source code using a different engine:

``````
D3DXQUATERNION qBikeRotation;
iVectorRotate(&vUp,&vUp,&qBikeOrigin);
iQuaternionLookAt(&qBikeRotation,&vScanDownCp,&(vScanDownCp+vScanDownCn),&vUp);
D3DXQUATERNION qForward;
iQuaternionFromEulerAngles(&qForward,-90.0f,180.0f,0.0f);
iQuaternionMultiply(&qBikeRotation,&qForward,&qBikeRotation);

``````

This gives me the rotation relative to the up vector of my source (qBikeOrigin in this case). I can then use this rotation to apply directly to my object. In effect, it will rotate an object to match the hit normal. Say hello F-zero.

This is how the bluerpint looks, but, without being able to declare the Up vector in the “FindLookAtRotation” function. It cant be done.

Does anyone know a way around this, or, is there another method?
Cheers,
Dan

Blueprints exposes a function that will give you a rotator from axis and angle inputs. Axis angle form is great for interpolating.

What you will need to do is get the the vector between your actor and the target call it L. Lets call your Forward vector F

F Cross L = Axis
Norm(F) dot Norm(L) = cos(Theta)
You can get Theta with arccos

Then you can pull out a rotator of any angle between 0 and Theta on the Axis of rotation if you need a sub-step.

Edit: forgot cosine!

Hi James,

Thanks for the reply. I did try your method but with my lack of knowledge in dot/cross (never used them before, lookatrotation was my tool of choice with declaring up vector), didnt get very far.
I’ve been reading up on this after your advice http://www.euclideanspace.com/maths/algebra/vectors/angleBetween/, but still havnt been able to fully grasp it yet.

I did manage to obtain the rotations needed using this method below, however, i’am not sure its the “best method”. Even with Lerp the results are very jumpy.
If you have any advice, i’d appreciate it.