public void LockOn(Vector3 botPos, Vector3 botVel, GameObject LockBot) { Vector3 LockBotPos = LockBot.transform.position; //Aim Estimator Vector3 velocity = ((LockBotPos - posPrev) / Time.deltaTime); Vector3 relVel = (velocity); float dist = Vector3.Distance(botPos, LockBotPos); //Random Maker Vector3 Randomizer = new Vector3(UnityEngine.Random.Range(-randomMax, randomMax), UnityEngine.Random.Range(-randomMax, randomMax), UnityEngine.Random.Range(-randomMax, randomMax)); //Offset Maker Vector3 OffsetValue = LockBot.transform.TransformPoint(new Vector3(xOffset, yOffset, zOffset)) - LockBotPos; Vector3 estPosW = Util.PosEstimate(botPos, LockBotPos, botVel, velocity, UnityEngine.Random.Range(380, 420)); Vector3 estPos = estPosW; posPrev = LockBotPos; //Orbit Maker float xCircle = Mathf.Sin(Mathf.PI * (Time.time / orbitSpeed)) * orbitRadius; float zCircle = Mathf.Cos(Mathf.PI * (Time.time / orbitSpeed)) * orbitRadius; Vector3 orbitCircle = new Vector3(xCircle, orbitHeight, zCircle); //Draw Line Stuff if (drawLines) { // ap.DrawLine3D(Color.red,botPos,LockBotPos); ap.DrawLine3D(Color.green, LockBotPos, LockBotPos + orbitCircle); ap.DrawLine3D(Color.blue, LockBotPos + (LockBot.transform.right * 10), LockBotPos + (LockBot.transform.forward * 10)); ap.DrawLine3D(Color.blue, LockBotPos + (LockBot.transform.right * -10), LockBotPos + (LockBot.transform.forward * 10)); ap.DrawLine3D(Color.magenta, LockBotPos, LockBotPos + OffsetValue); ap.DrawLine3D(Color.yellow, LockBotPos + OffsetValue, OffsetValue + estPos); // ap.DrawLine3D(Color.black,ap.GetCameraPosition(),hitPos); } //Lock On Toggle System if (lockOnStat) { ap.SetAimPosition(1, Randomizer + OffsetValue + estPos); // ap.SetAimPosition(5,LockBotPos + Randomizer+OffsetValue+estPos); // ap.SetAimPosition(5,LockBot.transform.position+orbitCircle); } else { ap.SetAimPosition(1, new Vector3(0, 0, 0)); // ap.SetAimPosition(5,new Vector3(0,0,0)); // ap.SetAimPosition(6,new Vector3(0,0,0)); } //Debug text switch (selectMode) { case 1: modeText = "X Offset"; break; case 2: modeText = "Y Offset"; break; case 3: modeText = "Z Offset"; break; case 4: modeText = "Random"; break; case 5: modeText = "Orbit Radius"; break; case 6: modeText = "Orbit Height"; break; case 7: modeText = "Orbit Speed"; break; } // ap.Print(0, LockBot.name); // ap.Print(1, "range : " + dist ); // ap.Print(2, "Mode : " + modeText ); // ap.Print(3, "Rng : " + randomMax ); // ap.Print(4, "Offset : " + new Vector3(xOffset,yOffset,zOffset) ); // ap.Print(5, "Orbit : " + new Vector3(orbitRadius,orbitHeight,orbitSpeed) ); }