Skip to content

perf(UEHelpers): Fast path for GetPlayerController#1050

Open
UE4SS wants to merge 1 commit intomainfrom
uehelpers-plyctrl-speed
Open

perf(UEHelpers): Fast path for GetPlayerController#1050
UE4SS wants to merge 1 commit intomainfrom
uehelpers-plyctrl-speed

Conversation

@UE4SS
Copy link
Copy Markdown
Collaborator

@UE4SS UE4SS commented Oct 22, 2025

Description

It now tries to get the player controller via GameInstance.LocalPlayers[0], and only falls back on the slow FindAllOf method if that fails.

Type of change

  • Other... Please describe: Performance improvement

How has this been tested?

The following script was run, followed by jumping in Palworld.
No testing has been performed on any other game, or on any server software.

RegisterHook("/Script/Engine.Character:CanJumpInternal", function(ContextParam)
    local Controller = UEHelpers.GetPlayerController()
    if Controller:IsValid() then
        print(string.format("Controller: %s\n", Controller:GetFullName()))
    end
end)

It now tries to get the player controller via GameInstance.LocalPlayers[0], and only falls back on the slow FindAllOf method if that fails.
@joric
Copy link
Copy Markdown

joric commented Oct 22, 2025

Much faster now, after the performance-killing change in #1047 (I was getting like 10 fps, instead of 60), but now it also returns debug camera controller (if active). It broke my teleport code (DebugCamera.lua), because in debug camera mode it returns debug camera controller and there's no pawn there so you'd need a fallback function to get the actual player controller with a pawn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants