Combining two rotation

Hello, I’m trying to make a 3rd person character controller that works on a planet. I have created 2 rotations, one rotates around the character using standard mouse input (to look left and right), and the other rotation is used to make it seem like the player is always on a flat surface no matter where they are on the planet.

var mouseRotation = Quaternion.AngleAxis(yTargetRotation, Vector3.up);
var planetRotation = Quaternion.FromToRotation(transform.up, transform.position);
var finalRotation = ?;
transfrom.rotation = finalRotation;

Rundown

  1. yTargetRotation is total “Mouse X” input over the frames
  2. it takes the character’s green arrow (transfrom.up) and points it so it faces away from the origin
  3. ? I need help combining 1 and 2
  4. set the rotation to final rotation.

when working with Quaternions you can combine them simply by multiplying them together.

2 Likes

This… but you can also use two Transforms in a hierarchy, such as how I did this battleship gun turret thing:

Turret aiming/rotating:

https://discussions.unity.com/t/783469/2

ALSO: for planetary stuff there’s a few more things to think about. I implemented this guy’s stuff and it was pretty simple to understand what he did:

https://www.youtube.com/watch?v=TicipSVT-T8

Full source in video comments.