forceTeleport
Definition
-- @/lua/ge/extensions/gameplay/traffic.lua:260
local function forceTeleport(id, pos, dir, minDist, maxDist, targetDist) -- force teleports a traffic vehicle
if traffic[id] and traffic[id].ignoreForceTeleport then return end -- ignoreForceTeleport is a special flag for vehicles that should not be force teleported
local vehObj = getObjectByID(id)
if vehObj and vehObj:getActive() then
mapNodes = map.getMap().nodes
pos = pos or core_camera.getPosition()
dir = dir or core_camera.getForward()
minDist = minDist or 100
maxDist = maxDist or 500
targetDist = targetDist or min(minDist * 2, lerp(minDist, maxDist, 0.5))
--if traffic[id] then
--traffic[id].respawn.pos = vec3(0, 0, -1000) -- temporary, prevents conflicts (remove later)
--end
local spawnData = gameplay_traffic_trafficUtils.findSafeSpawnPoint(nil, nil, minDist, maxDist, targetDist)
local newPos, newRot = gameplay_traffic_trafficUtils.finalizeSpawnPoint(spawnData.pos, spawnData.dir, spawnData.n1, spawnData.n2, {legalDirection = true})
newRot = quatFromDir(newRot, map.surfaceNormal(newPos))
respawnVehicle(id, newPos, newRot)
end
end
Callers
@/lua/ge/extensions/editor/trafficDebug.lua
if im.Button("Force Respawn") then
gameplay_traffic.forceTeleport(currVeh.id)
end
@/gameplay/missionTypes/aiRace/customNodes/aiScatterNode.lua
if id ~= be:getPlayerVehicleID(0) then
gameplay_traffic.forceTeleport(id, nil, nil, 250, 1000)
end
@/gameplay/missionTypes/evade/customNodes/scatterTrafficAwayNode.lua
or (not self.pinIn.inverted.value and v.pos:squaredDistance(vec3(self.pinIn.pos.value)) <= square(self.pinIn.radius.value)) then
gameplay_traffic.forceTeleport(id)
end
@/lua/ge/extensions/gameplay/traffic.lua
for _, id in ipairs(vehIds) do
forceTeleport(id, nil, nil, minDist, maxDist)
end
else
forceTeleport(newId, nil, -focus.dirVec) -- force teleports the vehicle behind the player view (not an ideal solution)
end
else
forceTeleport(vehId, nil, nil, traffic[vehId]._teleportDist)
end
if veh._teleport then
forceTeleport(id, nil, nil, veh._teleportDist)
else
@/lua/ge/extensions/gameplay/parking.lua
local function forceTeleport(vehId, psList, minDist, maxDist) -- forces a parked car to teleport to a new parking spot
if not parkedVehData[vehId] or parkedVehData[vehId].ignoreForceTeleport then return end -- ignoreForceTeleport is a special flag for vehicles that should not be force teleported
for _, id in ipairs(vehIds) do
forceTeleport(id, randomPsList)
end
if otherVeh:getPosition():squaredDistance(getObjectByID(vehId):getPosition()) < square(radius) then
forceTeleport(vehId, nil, 100)
break
if currVeh._teleport then
forceTeleport(currId, nil, 100)
end
@/lua/ge/extensions/career/modules/inspectVehicle.lua
for _, vehId in ipairs(vehicleIds) do
gameplay_traffic.forceTeleport(vehId)
end
@/lua/ge/spawn.lua
if otherId ~= vehID and (not map.isCrashAvoidable(otherId, bbCenter, vehRadius) or intersectingOtherVehicle(getObjectByID(otherId), axis0, axis1, axis2, halfExtentsX, halfExtentsY, halfExtentsZ, bbCenter)) then
gameplay_traffic.forceTeleport(otherId, bbCenter)
end