Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool ParkingDistance(Vector3 pos1, Vector3 pos2, double maxDistance) {
- double distance = Math.Sqrt((pos2.x - pos1.x) * (pos2.x - pos1.x) + (pos2.y - pos1.y) * (pos2.y - pos1.y) + (pos2.z - pos1.z) * (pos2.z - pos1.z));
- if (distance <= maxDistance) {
- return true;
- } else {
- return false;
- }
- }
- bool CheckRotation(Quaternion quat1, Quaternion quat2, double[] checks) {
- double difference = Math.Sqrt((quat2.x - quat1.x) * (quat2.x - quat1.x) + (quat2.y - quat1.y) * (quat2.y - quat1.y) + (quat2.z - quat1.z) * (quat2.z - quat1.z) + (quat2.w - quat1.w) * (quat2.w - quat1.w));
- difference = Math.Round(difference, 1);
- if(Array.Exists(checks, element => element == difference)) {
- return true;
- } else {
- return false;
- }
- }
- void TimerCallback() {
- Vector3 playerPos = GameObject.FindWithTag("Lambo").transform.position;
- Quaternion playerRotation = GameObject.FindWithTag("Lambo").transform.rotation;
- bool InRange = ParkingDistance(transform.position, playerPos, 3.5);
- bool InRotation = CheckRotation(transform.rotation, playerRotation, new double[] {1.4, 1.8 });
- if (InRange && InRotation) {
- GUI.ToggleWinMsg(true);
- CheckForParking = false;
- HideWinMsg = true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement