Advertisement
Whiplash141

Seff Raycast Random Direction

Oct 20th, 2016
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.27 KB | None | 0 0
  1. MyEntitySubpart subpart1 = cubeBlock.GetSubpart("MissileTurretBase1");
  2. MyEntitySubpart subpart2 = subpart1.GetSubpart("MissileTurretBarrels"); ;
  3. //MyAPIGateway.Utilities.ShowNotification("Dif: " + (currentShootTime - lastShootTime), 17, MyFontEnum.Blue);
  4.  
  5. //Constants
  6. double maxDevianceAngle = 0.1;
  7. double maxRange = 800;
  8. double minRange = 6;
  9. double horizOffset = 1.5;
  10.  
  11. //Generate random seed
  12. System.Random rand = new System.Random();
  13.  
  14. //Generate random offsets
  15. double pitchDeviance = rand.NextDouble() * System.Math.Tan(maxDevianceAngle * System.Math.PI / 180) * (maxRange - minRange) * rand.Next(-1, 2);
  16. double yawDeviance = rand.NextDouble() * System.Math.Tan(maxDevianceAngle * System.Math.PI / 180) * (maxRange - minRange) * rand.Next(-1, 2);
  17.  
  18. //Construct destinations
  19. from = subpart2.WorldMatrix.Translation + subpart2.WorldMatrix.Forward * minRange;
  20. to = subpart2.WorldMatrix.Translation + subpart2.WorldMatrix.Forward * maxRange + subpart2.WorldMatrix.Left * yawDeviance + subpart2.WorldMatrix.Up * pitchDeviance;
  21. fromLB = subpart2.WorldMatrix.Translation + subpart2.WorldMatrix.Forward * minRange + subpart2.WorldMatrix.Left * horizOffset;
  22. fromRB = subpart2.WorldMatrix.Translation + subpart2.WorldMatrix.Forward * minRange + subpart2.WorldMatrix.Right * horizOffset;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement