We get it. We use ad blockers too. But GameDev.net displays them so we can continue to be a great platform for you.
Please whitelist GameDev.net and our advertisers.
Also consider a GDNet+ Pro subscription to remove all ads from GameDev.net.
Subscribe to GameDev.net's newsletters to receive the latest updates and exclusive content.
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
Posted 23 November 2012 - 04:09 PM
Posted 23 November 2012 - 10:34 PM
Posted 25 November 2012 - 06:31 AM
Posted 25 November 2012 - 04:33 PM
private static bool IsTargeted(Weaponry.Weapon weapon, PhysicsObject target, Player p) { var shootPosition = weapon.GetShootPosition(); var shootSpeed = weapon.GetShootVelocity().Length(); // Quadratic formula to calculate time for leading the shot Vector3 shootVelocity = shootSpeed * p.Look; var speedSquared = Square(shootSpeed); var velocityDelta = shootVelocity - target.Velocity; var positionDelta = shootPosition - target.Position; var a = Square(velocityDelta.X) + Square(velocityDelta.Y) + Square(velocityDelta.Z); var b = 2f * (shootPosition.X * shootVelocity.X - shootPosition.X * target.Velocity.X - target.Position.X * shootVelocity.X + target.Position.X * target.Velocity.X + shootPosition.Y * shootVelocity.Y - shootPosition.Y * target.Velocity.Y - target.Position.Y * shootVelocity.Y + target.Position.Y * target.Velocity.Y + shootPosition.Z * shootVelocity.Z - shootPosition.Z * target.Velocity.Z - target.Position.Z * shootVelocity.Z + target.Position.Z * target.Velocity.Z); var c = Square(positionDelta.X) + Square(positionDelta.Y) + Square(positionDelta.Z) - Square(target.Radius) - Square(weapon.BulletRadius); // Evaluate the quadratic formula, with a little modification var inner = Square(b) - 4 * a * c; var latterPart = (float)Math.Sqrt(inner); return inner >= 0 && ((-b + latterPart) / a > 0 || (-b - latterPart) / a > 0); }
Edited by jsuffolk, 25 November 2012 - 06:37 PM.
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
GameDev.net™, the GameDev.net logo, and GDNet™ are trademarks of GameDev.net, LLC.