Hello everyone,
I am currently in the process of learning UE5 with a bunch of different projects and I faced an issue when scripting with blueprint in a particular project.
Context
The project is a local multiplayer one. Two controllers plugged to the same computer, one camera and two characters.
So far, everything works (almost) - another character is added to the level thanks to CreateLocalPlayer
which also creates everything related to the character:
- A player controller
- A player state
- An instance of my user widget
I want to have 2 User Widget Blueprints in my scene, one for each character.
The first issue I had was that the second instance of my UW_GameHUD
was not “automatically” attached to the second player.
The way I fixed this is not beautiful at all but it seems to works so far, so I don’t really care for now, I put it here for context in case it has a side effect:
This little HUD I have is basically and image that should follow the PlayerCharacter
in the world. It works totally fine for Player 1.
Here is the logic:
(on the right is just some debug, don’t mind it)
The issue
When Project World Location to Widget Position
is called for player two, it always returns (0,0), even if the second actor is at the exact same place as the one for player 1.
Here are some debug generated during EventTick
:
In blue, the debug associated to Player 1, in tred the one associated to Player 2.
Just to make sure everything is clear, here are the debug:
- first one is
self.GetDisplayName
- second one is
owningPlayerController.getDisplayName
(see screenshot #1) - third one is the yellow line from
GetActorLocation
that you can see on the screenshot #2 - last one is the dark blue line from
ProjectWorldLocationToWidgetPosition
you can see from screenshot #2
I have no clue what is going on, if someone could help me understand what is going it would be amazing!
Thanks and take care!