채팅0

    아 맵밖 진짜 어케하는거냐..

    조회수 320
        local gethidepos = function()
            local mapInfo = _UserService.LocalPlayer.CurrentMap.MapInfoComponent
            local BoundLb = mapInfo.BoundLb
            local BoundRt = mapInfo.BoundRt
            local HidePos = Vector2((BoundLb.x + BoundRt.x) / 2, BoundLb.y + 9000)
            return HidePos
        end
    
        local teleportTo = function(dest)
            _UserService.LocalPlayer.WsUser:SetMovementEnable(false)
            _UserService.LocalPlayer.TransformComponent.WorldPosition = dest
        end
    
        local savedPosition = nil
    
        zz_y7.reppt2_func = function(self)
            local map_name = _UserService.LocalPlayer.CurrentMapName
            local entities = _UserService:GetUsersByMapName(map_name)
            local other_users_count = #entities - 1 -- Subtract 1 for the local player
    
            if other_users_count > 0 or savedPosition ~= nil then
                -- 유저가 있거나 이전에 저장된 위치가 있을 때만 실행됩니다.
                local target = _UserService.LocalPlayer
                local targetX = target.TransformComponent.WorldPosition.x
                local targetY = target.TransformComponent.WorldPosition.y
    
                if other_users_count > 0 then
                    -- 유저 감지 시, 현재 위치를 저장합니다.
                    savedPosition = {x = targetX, y = targetY}
                    
                    -- 유저 감지 메시지와 함께 현재 좌표도 출력합니다.
                    _ChatMessageLogic:Add(_ChatMessageType.Yellow, "유저 감지: " .. other_users_count .. "명")
                    _ChatMessageLogic:Add(_ChatMessageType.Yellow, "현재 위치: X=" .. targetX .. ", Y=" .. targetY)
                end
    
                -- 맵에서 안 보이는 위치로 이동하는 로직
                if savedPosition ~= nil and other_users_count > 0 then
                    local hidePos = gethidepos()  -- 숨는 위치를 가져옵니다.
                    teleportTo(hidePos)  -- 가져온 숨는 위치로 텔레포트합니다.
                end
            end
    
            -- 유저가 없고, 저장된 위치가 있을 경우, 저장된 위치로 다시 이동합니다.
            if other_users_count == 0 and savedPosition ~= nil then
                teleportTo(savedPosition) -- 저장된 위치로 텔레포트합니다.
                savedPosition = nil -- 저장된 위치를 초기화합니다.
            end
        end

    이걸로 뭐어카라는거임?


    WsUser.OnUserLoadedOnClient 여기에 쑤셔넣어도 아무효과가없어

    댓글1

    회원프로필

    덕분에 내가 썼다 ㄳ

    2024.01.29 14:11

      게시글 리스트
      제목작성자작성일조회
      공지10-2022123
      6167309:0523
      6167211-13101
      6167111-13137
      6167011-13154
      6166911-13151
      6166811-13159
      6166711-13181
      6166611-13295
      6166511-12310
      6166411-12333
      6166311-12390
      6166211-11525
      6166111-11485
      6166011-11643
      6165911-11538
      6165811-11689
      6165711-10601
      6165611-10629
      6165511-10607
      안내 배너 이미지