internal override void Update(MySmallShipBot bot)
        {
            base.Update(bot);

            MyEntity enemy = bot.GetClosestEnemy();
            if (enemy != null)
            {
                Vector3 enemyToBot = bot.GetPosition() - enemy.GetPosition();
                float distance = enemyToBot.Length();
                if (distance <= bot.RunAwayDistance)
                {
                    Vector3 enemyToBotDirection = enemyToBot / distance;
                    Vector3 escapeTarget = bot.GetPosition() + enemyToBotDirection * 1000;
                    bot.Move(escapeTarget, escapeTarget, bot.WorldMatrix.Up, false);
                }
            }
        }
Example #2
0
        internal override void Update(MySmallShipBot bot)
        {
            base.Update(bot);

            MyEntity enemy = bot.GetClosestEnemy();

            if (enemy != null)
            {
                Vector3 enemyToBot = bot.GetPosition() - enemy.GetPosition();
                float   distance   = enemyToBot.Length();
                if (distance <= bot.RunAwayDistance)
                {
                    Vector3 enemyToBotDirection = enemyToBot / distance;
                    Vector3 escapeTarget        = bot.GetPosition() + enemyToBotDirection * 1000;
                    bot.Move(escapeTarget, escapeTarget, bot.WorldMatrix.Up, false);
                }
            }
        }