void AimTurret() { GameObject currentTargetObj = turretCurrentTarget == 1 ? target1 : target2; turretAimWaitTimer -= Time.deltaTime; Quaternion newRot = GenericFunctions.GetLookRotation(transform, currentTargetObj.transform); Vector3 adjustedRot = newRot.eulerAngles; adjustedRot = new Vector3(0, 0, adjustedRot.z + 180f); if (transform.rotation.eulerAngles.z >= adjustedRot.z - 10 && transform.rotation.eulerAngles.z <= adjustedRot.z + 10) { if (turretAimWaitTimer <= 0) { turretAimWaitTimer = turretWaitTimer; } turretCurrentTarget = turretCurrentTarget == 1 ? 2 : 1; } if (turretAimWaitTimer <= 0) { transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(adjustedRot), Time.deltaTime / 1f); } }
void AimTurretTowardsPlayer() { Quaternion newRot = GenericFunctions.GetLookRotation(transform, Dima.transform); Vector3 adjustedRot = newRot.eulerAngles; adjustedRot = new Vector3(0, 0, adjustedRot.z + 180f); transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(adjustedRot), Time.deltaTime / 0.5f); }
void RotationAdjust() { Quaternion newRot = GenericFunctions.GetLookRotation(transform, crosshair); Vector3 adjustedRot = newRot.eulerAngles; adjustedRot = dimaScript.spriteRotation == 1 ? new Vector3(0, 0, adjustedRot.z + 160f) : new Vector3(0, 0, adjustedRot.z + 20f); transform.rotation = Quaternion.Euler(adjustedRot); }
void Start() { Vector3 middlePoint = (rail_end_1.transform.position + rail_end_2.transform.position) / 2; Quaternion lookRot = GenericFunctions.GetLookRotation(rail_end_1.transform, rail_end_2.transform); float distance = GenericFunctions.GetDistance(rail_end_1, rail_end_2); wire.position = middlePoint; wire.rotation = lookRot; wire.localScale = new Vector3(distance - (distance / 1.21f), wire.transform.localScale.y, wire.transform.localScale.z); }
void Start() { overlord = GameObject.Find("OVERLORD").GetComponent <Overlord_script>(); Dima = GameObject.Find("Dima"); dimaScript = Dima.GetComponent <Dima_script>(); Vector3 middlePoint = (laser_A.transform.Find("Laser_Target_A").position + laser_B.transform.Find("Laser_Target_B").position) / 2; middlePointObject = Instantiate(new GameObject(), middlePoint, Quaternion.identity); Quaternion lookRot = GenericFunctions.GetLookRotation(laser_A.transform, laser_B.transform); float distance = GenericFunctions.GetDistance(laser_A.transform.Find("Laser_Target_A").gameObject, laser_B.transform.Find("Laser_Target_B").gameObject); if (isDeathLaser) { beam_A1.SetActive(false); beam_A2.SetActive(false); beam_D.transform.position = middlePoint; beam_D.transform.rotation = lookRot; beam_D.transform.localScale = new Vector3(distance - (distance / 7), beam_D.transform.localScale.y, beam_D.transform.localScale.z); } else { beam_D.SetActive(false); beam_A1.transform.position = middlePoint; beam_A1.transform.rotation = lookRot; beam_A1.transform.localScale = new Vector3(distance - (distance / 7), beam_A1.transform.localScale.y, beam_A1.transform.localScale.z); beam_A2.transform.position = middlePoint; beam_A2.transform.rotation = lookRot; beam_A2.transform.localScale = new Vector3(distance - (distance / 7), beam_A2.transform.localScale.y, beam_A2.transform.localScale.z); } laser_Ball_A = laser_A.transform.Find("Laser_ball").gameObject; laser_Ball_D_A = laser_A.transform.Find("Laser_ball_D").gameObject; laser_Ball_A1_A = laser_A.transform.Find("Laser_ball_A1").gameObject; laser_Ball_A2_A = laser_A.transform.Find("Laser_ball_A2").gameObject; laser_Ball_B = laser_B.transform.Find("Laser_ball").gameObject; laser_Ball_D_B = laser_B.transform.Find("Laser_ball_D").gameObject; laser_Ball_A1_B = laser_B.transform.Find("Laser_ball_A1").gameObject; laser_Ball_A2_B = laser_B.transform.Find("Laser_ball_A2").gameObject; }
void LookAtTarget() // rotate head to look at crosshair { float maxRotUp = dimaScript.spriteRotation == 1 ? 125 : 240; float maxRotDown = dimaScript.spriteRotation == 1 ? 412 : 300; Quaternion lookRot = GenericFunctions.GetLookRotation(crosshair, transform); Vector3 adjustedRot = lookRot.eulerAngles; adjustedRot = new Vector3(0, 0, adjustedRot.z + 90); if (dimaScript.spriteRotation != latestSpriteRot) { if (latestRot.z <= 92 || latestRot.z <= 240) { latestRot.z = dimaScript.spriteRotation == 1 ? latestRot.z + 230 : latestRot.z - 230; // TODO: adjust thse more precicely } else if (adjustedRot.z >= 450 || adjustedRot.z >= 300) { latestRot.z = dimaScript.spriteRotation == 1 ? latestRot.z + 100 : latestRot.z - 100; // TODO: adjust thse more precicely } latestSpriteRot = dimaScript.spriteRotation; } if (dimaScript.spriteRotation == 1) { latestRot = new Vector3(0, 0, Mathf.Abs(latestRot.z)); } else { transform.rotation = Quaternion.Euler(new Vector3(0, 0, -transform.rotation.z)); } if (dimaScript.spriteRotation == 1 && adjustedRot.z >= 92 && adjustedRot.z <= 125 || dimaScript.spriteRotation == 1 && adjustedRot.z <= 450 && adjustedRot.z >= 412) { latestRot = adjustedRot; } else if (dimaScript.spriteRotation == -1 && adjustedRot.z >= 240 && adjustedRot.z <= 300) { latestRot = adjustedRot; } transform.rotation = Quaternion.Euler(latestRot); }
void RotateConnector() { Quaternion lookRot = GenericFunctions.GetLookRotation(controlScript.rail_end_1.transform, controlScript.rail_end_2.transform); transform.rotation = lookRot; }
void LookAtCrosshair() { parent.position = isRightHand ? target_R.position : target_L.position; parent.rotation = GenericFunctions.GetLookRotation(crosshair, transform); }
void SetStartDirection() // set intitial direction and rotation { direction = GenericFunctions.Vector3ZeroZ(crosshair.transform.position - transform.position).normalized; transform.rotation = GenericFunctions.GetLookRotation(crosshair.transform, transform); }