Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Aiming()
- {
- mousePosInScene = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, -startPos.z));
- mousePosInScene.z = startPos.z - 0.171f;
- float weaponDotProduct = Vector3.Dot((weaponAnkor.transform.position - weaponCenter.transform.position).normalized, (gameObject.transform.rotation * new Vector3(0, 0, 1)).normalized);
- float mouseDotProduct = Vector3.Dot((mousePosInScene - weaponCenter.transform.position).normalized, (gameObject.transform.rotation * new Vector3(0, 0, 1)).normalized);
- if (weaponDotProduct > maxWeaponAimingAngle)
- {
- weaponRotationBackup = weaponCenter.transform.rotation;
- headRotationBackup = headBone.transform.rotation;
- headBone.transform.rotation = Quaternion.LookRotation(mousePosInScene - headBone.transform.position);
- weaponCenter.transform.rotation = Quaternion.Lerp(weaponCenter.transform.rotation, Quaternion.LookRotation(mousePosInScene - weaponCenter.transform.position), 5f * Time.deltaTime);
- weaponDotProduct = Vector3.Dot((weaponAnkor.transform.position - weaponCenter.transform.position).normalized, (gameObject.transform.rotation * new Vector3(0, 0, 1)).normalized);
- if (weaponDotProduct <= maxWeaponAimingAngle)
- {
- headBone.transform.rotation = headRotationBackup;
- weaponCenter.transform.rotation = weaponRotationBackup;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement