public override BehaviourTreeStatus Tick() { AdvancedRobot tmpBot = this.bb.Robot; ScannedRobotEvent e = this.bb.CurrentEnemy.E; if (tmpBot.Time % 50 == 0) { //this.bb.MovementDirection *= -1; } if (this.bb.DirectHit) { tmpBot.SetBack(distance); this.bb.DirectHit = false; } if (e == null) { this.bb.Robot.SetTurnRadarRight(360); return(BehaviourTreeStatus.Success); } var gunTurnAmt = Utils.NormalRelativeAngleDegrees(e.Bearing + (this.bb.Robot.Heading - this.bb.Robot.RadarHeading)); // If our target is too far away, turn and move toward it. if (e.Distance > 150) { gunTurnAmt = Utils.NormalRelativeAngleDegrees(e.Bearing + (this.bb.Robot.Heading - this.bb.Robot.RadarHeading)); //tmpBot.SetTurnGunRight(gunTurnAmt); // Try changing these to setTurnGunRight, tmpBot.SetTurnLeft(normaliseBearing(e.Bearing + 90 - (15 * this.bb.MovementDirection))); // and see how much Tracker improves... // (you'll have to make Tracker an AdvancedRobot) tmpBot.SetAhead((e.Distance - 140) * this.bb.MovementDirection); return(BehaviourTreeStatus.Success); } // Our target is close. gunTurnAmt = Utils.NormalRelativeAngleDegrees(e.Bearing + (this.bb.Robot.Heading - this.bb.Robot.RadarHeading)); //tmpBot.SetTurnGunRight(gunTurnAmt); // Our target is too close! Back up. if (e.Distance < 100) { tmpBot.SetTurnLeft(normaliseBearing(e.Bearing + 90 - (15 * this.bb.MovementDirection))); // and see how much Tracker improves... this.bb.MovementDirection = 1; if (e.Bearing > -90 && e.Bearing <= 90) { this.bb.Robot.SetBack(distance * this.bb.MovementDirection); } else { this.bb.Robot.SetAhead(distance * this.bb.MovementDirection); } } //tmpBot.Ahead(distance * r); return(BehaviourTreeStatus.Success); }