animating one property of a Quaternion

Hello!

I’m building a cube for a first person to walk inside.

When you get to a face of the cube, inside of it, the cube will roll in that face direction, so the first person will walk on the wall.

So I have a trigger near to each cube edge, and:

//function to deal with the cube rotation
function OnTriggerEnter () {
	rotateCube();
	rotateCamera();
}

//cube rotation
function rotateCube(){
	Ani.Mate.To(cubo, 2, {"rotation": Quaternion.Euler(nowRotX + rotationX, nowRotY + rotationY, nowRotZ + rotationZ), "drive": SlerpDrive});
	
}


//camera rotation
function rotateCamera(){
	cameraHandler = myCamera.GetComponent(MouseLook);
	cameraHandler.originalRotation.x = -1;
	Ani.Mate.To(myCamera.transform.localRotation, 2, {"x": -1});
}

myCamera is using MouseLook Script. So, to change camera rotation, when I’m on the wall, I need to access its originalRotation properties.

I’m trying to animate this preperties changing so it could be a more soft trasition, but Ani.Mate isn’t working here!

I’ve placed before both ways that I’m using to change originalRotation.x, for example so you could see what I’m trying to:

cameraHandler.originalRotation.x = -1;
	Ani.Mate.To(myCamera.transform.localRotation, 2, {"x": -1});

Any idea why Ani.Mate isn’t working?
or
Can I use any other way to change originalRotation.x from 0 to -1, for example, but having animation on it?

The cube rotation is working properly!

Thanks in advance!!

where you see:

 Ani.Mate.To(myCamera.transform.localRotation, 2, {"x": -1});

should be:

 Ani.Mate.To(cameraHandler.originalRotation, 2, {"x": -1});

Sorry!

anyone!?

I haven’t worked with Ani.Mate, but I suspect you are modifying the x of the Quaternion here, which is not the same as rotation around the x-axis. Try adding .eulerAngles after originalRotation.

If the compiler doesn’t accept that, you’ll probably have to animate a float instead and assign it to cameraHandler.originalRotation.eulerAngles.x every frame.

If you understand Quaternions and really want to animate the Quaternion x value, pretend I didn’t write this ;).

well, thank you very much for the reply!

Because I don’t understand Quaternions, i’ve left this way to do this :stuck_out_tongue: