Vehicle.moveTo ▲ 43

Available from Easy Red 2 2.1.1

Orders the AI crew to drive the vehicle to a position and keep it within radius metres of it. The gunners keep engaging whatever they see, so a tank parked this way still fights: it just does not leave the spot.Under the hood this is the same hold area order the crew squad gets from squad.moveTo, applied to the squad sitting in the vehicle. squad.followLeader() on that squad releases it. The crew keeps driving around inside the radius, so use a small radius (3-5 m) for a sentinel and a bigger one for a patrol area.


Return value

Return TypeDescription
voidTrue if the order was given. False when a player is at the wheel, on planes, or when nobody is aboard.

Parameters

ParameterTypeDescription
1voidWhere to go, in world coordinates.
2NumberHow far from the position the vehicle may wander, in metres. Optional, 5 by default.

Examples

Vehicle as a sentinel

-- the nearest tank to the crossroads parks there and guards it
local crossroads = vec3(412, 31, 870)
local tank = er2.getNearestVehicle(crossroads, 300)
if tank ~= nil then
    if tank:moveTo(crossroads, 4) then
        er2.print("The tank is moving to the crossroads")
    end
end

-- later: let the crew follow its own orders again
-- tank:getLeader():getSquad():followLeader()

Back to Scripting API