/* (non-Javadoc) * @see com.soartech.simjr.sim.entities.AbstractEntity#tick(double) */ @Override public void processTick(double dt) { if (hit) { return; } Vector3 targetPos = target != null ? target.getPosition() : staticTarget; Vector3 dir = targetPos.subtract(getPosition()).normalized(); setHeading(Math.atan2(dir.y, dir.x)); setVelocity(dir.multiply(speed)); super.processTick(dt); Vector3 newPos = getPosition(); if (newPos.subtract(targetPos).length() < speed * dt * 1.5) { hit = true; getSimulation().detonate(new Detonation(getSimulation(), weapon, target, staticTarget)); // if (shooter != null) // { // removeFlyOut(shooter, this); // } weapon.removeFlyout(this); getSimulation().removeEntity(this); } }
public double getBearingToTarget() { Vector3 targetPos = target != null ? target.getPosition() : staticTarget; targetPos.subtract(getPosition()); return Math.toDegrees(Angles.boundedAngleRadians(Angles.getBearing(targetPos))); }