GE Lua Documentation

Press F to search!

forceTeleport

Definition


-- @/lua/ge/extensions/gameplay/parking.lua:255

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

  minDist = minDist or 0
  maxDist = maxDist or 10000
  psList = psList or findParkingSpots(focus and focus.pos, minDist, maxDist)

  for _, psData in ipairs(psList) do
    local ps = psData.ps
    if psData.squaredDistance >= square(minDist) and psData.squaredDistance <= square(maxDist) and checkParkingSpot(vehId, ps) then
      if parkedVehData[vehId].parkingSpotId then
        sites.parkingSpots.objects[parkedVehData[vehId].parkingSpotId].vehicle = nil
        parkedVehData[vehId].parkingSpotId = nil
      end

      moveToParkingSpot(vehId, ps, not getObjectByID(vehId):isReady())
      break
    end
  end
end

Callers

@/lua/ge/extensions/gameplay/parking.lua
  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/gameplay/traffic.lua

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
  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
@/gameplay/missionTypes/aiRace/customNodes/aiScatterNode.lua
    if id ~= be:getPlayerVehicleID(0) then
      gameplay_traffic.forceTeleport(id, nil, nil, 250, 1000)
    end
@/lua/ge/extensions/career/modules/inspectVehicle.lua
      for _, vehId in ipairs(vehicleIds) do
        gameplay_traffic.forceTeleport(vehId)
      end
@/lua/ge/extensions/editor/trafficDebug.lua
    if im.Button("Force Respawn") then
      gameplay_traffic.forceTeleport(currVeh.id)
    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
@/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