Hello all ,
I am having a hard time understanding what this code does : (it was taken from a tutorial but the explication wasn't clear enough to me)
I came to a point where I need this code but with a minor change . I can't change it since I don't understand it well.
The goal behind all of it is to make an object rotate around a certain pivot .
This object had a predefined position and rotation.
The problem with the code as it is is that the object will literally have a big jump from one position and rotation to a completely new position and rotation once the code is activated.
It should not jump like that but have a smooth entrance to this code.
If you can offer me any kind of help , i'll be really grateful.
Thanks for all in advance !
Kindly find the code down below:
//Horz and Vert are random values between -1f and 1f
Rotx += Horz * Time.deltaTime * RotSpeed;
Roty += Vert * Time.deltaTime * RotSpeed;
Quaternion Yrot = Quaternion.Euler(0f, Roty, 0f);
DestRotation = Yrot * Quaternion.Euler(Rotx, 0f, 0f);
DestRotation = Quaternion.Euler(Rotx, Roty, 0f);
transform.rotation = DestRotation;
transform.position = Pivot.position + transform.rotation * Vector3.forward * -PivotDistance;
↧