Wednesday, August 31, 2022
HomeGame Developmentunity - Getting the rotation round some extent

# unity – Getting the rotation round some extent

I’m presently simulating enter from some sensors – creating 4 factors in 3d house (which all lie on the identical aircraft and do not transfer relative to one another – so their relative place is thought when the aircraft is the bottom).

I do know my code reconstructing the rotation from the 4 factors is right.
However, I’m having a very laborious time creating the 4 factors to rotate the best way I need them to for this simulation.

I’ve a proper isosceles triangle (one with 2 sides of equal size, assembly at a 90 diploma angle. This assembly level is true on the origin) extruded right into a prism, with one face a part of the XY aircraft, and the opposite is a part of the YZ aircraft:

I wish to rotate ON the aircraft drawn on in purple, which the lengthy facet of the triangle.

``````    Vector3 p2c_offset = new Vector3(0, 0, -46.89f);
Vector3 p2l_offset = new Vector3(-31.95f, 0, -(18.44f + 46.89f));
Vector3 p2r_offset = new Vector3(36.28f, 0, -(20.94f + 46.89f));
var rot = Quaternion.LookRotation(Vector3.up, Vector3.proper) * Quaternion.LookRotation((Mathf.Sin(dt * 36 * Mathf.Deg2Rad) * Vector3.ahead + Mathf.Cos(dt * 36 * Mathf.Deg2Rad) * Vector3.proper), Vector3.up) * Quaternion.LookRotation(Vector3.ahead, new Vector3(-1, 0, -1));
var middle = new Vector3(-9.5f, 5, -9.5f);

var retVal = new Vector3[4];
retVal[0] = middle;

retVal[1] = middle + rot*p2c_offset;

retVal[2] = middle + rot*p2l_offset;

retVal[3] = middle+rot*p2r_offset;
``````

The factors are named pointer, middle, left, and proper. The offset vectors are added to the pointer level to search out the opposite factors, which as talked about, lie on the identical aircraft.
line #4 is my newest failed try.

I’ve tried setting the `remodel` place and rotation, utilizing `RotateAround`, after which grabbing the remodel place and rotation and inserting it into `retVal`. That code was for much longer and didn’t work accurately both.

code calculating `dt`:

``````void Update()
{
dt = (dt + Time.deltaTime) % nPosAndRots;
}
``````

RELATED ARTICLES