0

I have 4 arrows on my interface. One arrow points in one direction: up, down, left, right. When you select an arrow I want the player controller to rotate in that direction around a point while facing toward that point. I have kind of gotten lost in the logic of transforms, vectors and rotators (pitch, yaw, roll). Can anyone please help me out with this logic problem? I am working in blueprint.

Baby Coder
  • 759
  • 1
  • 7
  • 14
  • Please edit your question and add a code snippet you tried to use. It would help people answering your question greatly! Read more about [how to ask a great question](http://stackoverflow.com/help/how-to-ask). – methode Jul 02 '15 at 08:11

1 Answers1

0

As you are mixing the transformations in a non-commutative way, it's better to repeat the calculation every time you need it.

Requires 5 stages, a distance and two angles. A picture to clarify:

enter image description here

  1. Translate your player in the +ve Z-direction by the distance you want it to be away from the point
  2. Make it face the -ve Z-direction (0, 0, -1)
  3. Rotate it around the x-axis by θ (in a clockwise sense when you look down the axis) - matrix P
  4. Rotate it around the z-axis by ϕ (likewise) - matrix Q
  5. Translate it by the displacement from the origin to the point (so, the point expressed as its position vector) - matrix T

The matrices you need for P and Q: https://en.wikipedia.org/wiki/Rotation_matrix#Basic_rotations

I assume you know the translation matrix :)

Keep track of each angle and change them when the arrows keys are pressed. Also the final matrix you need is TPQ (multiply in this order); re-calculate it every time you need it - don't worry about the processing power needed.