void RotateCameraSteps(RotDir dir) { if (Arial) { return; } Vector3 currRot = transform.rotation.eulerAngles; // get current rotation currRot.y += (float)dir * rotAmount; // apply rotation transform.rotation = Quaternion.Euler(currRot); // set new rotation curr += (int)dir; // updating the current position curr = curr == positions.Length ? 0 : curr == -1 ? positions.Length - 1 : curr; // moving between the max position and the minimum position transform.position = new Vector3(positions[curr].x + anchorPoint.x, yPos, positions[curr].y + anchorPoint.z); // setting the position of the camera mainLight.transform.LookAt(anchorPoint); // rotation the light to face the platform }
public void RotCurrentModel(RotDir rotDir) { Vector3 center = currentAnim.transform.position; //look for one of this renderers SkinnedMeshRenderer ren = currentAnim.GetComponentInChildren <SkinnedMeshRenderer>(); if (ren != null) { center = ren.bounds.center; } else { MeshRenderer render = currentAnim.GetComponentInChildren <MeshRenderer>(); center = render.bounds.center; } switch (rotDir) { case RotDir.CCW: currentAnim.transform.RotateAround(center, currentAnim.transform.forward, -deltaZAngle); break; case RotDir.CW: currentAnim.transform.RotateAround(center, currentAnim.transform.forward, deltaZAngle); break; case RotDir.Left: currentAnim.transform.RotateAround(center, currentAnim.transform.up, deltaYAngle); break; case RotDir.Right: currentAnim.transform.RotateAround(center, currentAnim.transform.up, -deltaYAngle); break; case RotDir.Up: currentAnim.transform.RotateAround(center, currentAnim.transform.right, -deltaXAngle); break; case RotDir.Down: currentAnim.transform.RotateAround(center, currentAnim.transform.right, deltaXAngle); break; } }