Hi all,
I’m trying to add two Quaternion together, and when I move the item on a single axis it works fine however when I try and move it on multiple axis it has issues. See video.
This is my current code. The selectionOrder variable is a variable that holds all of the selected items within the editor view. In this instance its all of the cubes - you can see the selection order by looking at the #Numbers on each of the cube.
Since quaternion multiplication is not commutative that is unlikely to be what you want as transformRotation won’t be cancelled out by its inverse. So it could be that you get what you want by changing difference to
Wouldn’t it also work to just ignore this whole difference calculation thing and just set the rotations to the expected result? (note the commented out, no longer necessary first argument)
void spreadObjectsRotation(/* GameObject movedObj, */Quaternion moveToRotation){
for (int i = 0; i < selectionOrder.Count; i++){
selectionOrder[i].transform.rotation = moveToRotation;
}
}