Skip to content

Function Details

Aaron Warner edited this page Dec 12, 2022 · 2 revisions

Pull apart to figure how we switch enemies

function GetRandomEnemyPos(aiBrain)

    for k, v in ArmyBrains do
        if IsEnemy(aiBrain:GetArmyIndex(), v:GetArmyIndex()) and not v:IsDefeated() then
            if v:GetArmyStartPos() then
                local ePos = v:GetArmyStartPos()
                return ePos[1], ePos[3]
            end
        end
    end
    return false

end

-- Start and end positions local startPos = Vector3(1, 2, 3) local endPos = Vector3(4, 5, 6)

-- Distance to travel local distance = 10

-- Calculate the direction vector local dir = (endPos - startPos):normalized()

-- Calculate the interpolated position local pos = endPos - dir * distance

-- Output the interpolated position print("Interpolated position: ", pos)

-- Start and end positions local startPos = Vector3(1, 2, 3) local endPos = Vector3(4, 5, 6)

-- Distance to travel local distance = 10

-- Calculate the direction vector local dir = (endPos - startPos):normalized()

-- Calculate the interpolated position local pos = startPos + dir * distance

-- Output the interpolated position print("Interpolated position: ", pos)

why is chatgpt so smart!

Clone this wiki locally