Skip to main content

Look

Camera-direction replication for the senses that care where a player is looking. Exposed as VluxyAI.Sync.Look. The game makes one RemoteEvent; the client calls Look.Report with it, the server calls Look.Receive and hands the receiver's Eye to Watched or Perception.SeenByAnyone.

-- client
VluxyAI.Sync.Look.Report(ReplicatedStorage.Remotes.Look)

-- server
local looks = VluxyAI.Sync.Look.Receive(ReplicatedStorage.Remotes.Look)
:AddSense(VluxyAI.Senses.Watched.new({ Eye = looks.Eye }))

A player who has not reported, or whose last report is older than Timeout, falls back to whatever the caller does without an eye: the head's facing for Watched.

Functions​

Report​

Look.Report(
remote: RemoteEvent,--

Fired with the camera's CFrame.

) → Cleaner--

Destroy it to stop reporting.

Types

​

interface LookReportOptions {
Rate: number?--

Sends per second, at most. Default 10.

MinAngle: number?--

Radians the look direction must turn before a send. Default 0.02.

}

Client side. Watches workspace.CurrentCamera on Heartbeat and fires remote at most Rate times a second, and only when the look direction turned by more than MinAngle.

Receive​

Look.Receive() → LookReceiver

Types

​

interface LookReceiveOptions {
Timeout: number?--

Seconds after which a player's last report no longer counts. Default 2.

}

Server side. Keeps the latest camera rotation per player and forgets a player who leaves.

Show raw api
{
    "functions": [
        {
            "name": "Report",
            "desc": "Client side. Watches `workspace.CurrentCamera` on Heartbeat and fires `remote` at most\n`Rate` times a second, and only when the look direction turned by more than `MinAngle`.",
            "params": [
                {
                    "name": "remote",
                    "desc": "Fired with the camera's `CFrame`.",
                    "lua_type": "RemoteEvent"
                },
                {
                    "name": "options",
                    "desc": "",
                    "lua_type": "LookReportOptions?"
                }
            ],
            "returns": [
                {
                    "desc": "Destroy it to stop reporting.",
                    "lua_type": "Cleaner"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 98,
                "path": "lib/Sync/Look.luau"
            }
        },
        {
            "name": "Receive",
            "desc": "Server side. Keeps the latest camera rotation per player and forgets a player who leaves.",
            "params": [
                {
                    "name": "remote",
                    "desc": "",
                    "lua_type": "RemoteEvent"
                },
                {
                    "name": "options",
                    "desc": "",
                    "lua_type": "LookReceiveOptions?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "LookReceiver"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 141,
                "path": "lib/Sync/Look.luau"
            }
        }
    ],
    "properties": [],
    "types": [
        {
            "name": "LookReportOptions",
            "desc": "",
            "fields": [
                {
                    "name": "Rate",
                    "lua_type": "number?",
                    "desc": "Sends per second, at most. Default `10`."
                },
                {
                    "name": "MinAngle",
                    "lua_type": "number?",
                    "desc": "Radians the look direction must turn before a send. Default `0.02`."
                }
            ],
            "source": {
                "line": 34,
                "path": "lib/Sync/Look.luau"
            }
        },
        {
            "name": "LookReceiveOptions",
            "desc": "",
            "fields": [
                {
                    "name": "Timeout",
                    "lua_type": "number?",
                    "desc": "Seconds after which a player's last report no longer counts. Default `2`."
                }
            ],
            "source": {
                "line": 49,
                "path": "lib/Sync/Look.luau"
            }
        }
    ],
    "name": "Look",
    "desc": "Camera-direction replication for the senses that care where a player is looking. Exposed as\n`VluxyAI.Sync.Look`. The game makes one `RemoteEvent`; the client calls [Look.Report] with\nit, the server calls [Look.Receive] and hands the receiver's `Eye` to [Watched] or\n[Perception.SeenByAnyone].\n\n```lua\n-- client\nVluxyAI.Sync.Look.Report(ReplicatedStorage.Remotes.Look)\n\n-- server\nlocal looks = VluxyAI.Sync.Look.Receive(ReplicatedStorage.Remotes.Look)\n:AddSense(VluxyAI.Senses.Watched.new({ Eye = looks.Eye }))\n```\n\nA player who has not reported, or whose last report is older than `Timeout`, falls back to\nwhatever the caller does without an eye: the head's facing for Watched.",
    "source": {
        "line": 88,
        "path": "lib/Sync/Look.luau"
    }
}