#wdym, this is the begin play of the room
1 messages Β· Page 1 of 1 (latest)
Alright I'm gonna start a thread on this post π
So from what I see here, the room manager tries to initialize the state of all clips based on arrays in the game instance
sry π im trying to get itπ
no problem at all! Let's try to break it down
when do you update the game instance arrays?
inside the clips thmselves they have a pickup function i call when the player overlaps w their collision sphere
Can you try nuking this array completely and replacing it with the array from the save game data?
if you really need it - you can also set the value of that game instance array once the save game is loaded - just before loading the level
the clips also have this on begin play
It looks like your clips initialized in the proper state based on your video earlier - so maybe it's not an urgent bug to fix, but I would recommend having either the room manager handling clip states OR having clips handling their own state, but not both
ive jus been trying alot of things lol i been debugging this since last night π
clips also have a construction script
In your room manager's BeginPlay - once the ForEach is complete, can you have the room manager tell the UI to update the count?
you can either add a Sequence right after OnBeginPlay - or link it to the 'Completed' output of the foreach
kk
I like sequences personally, but its up to you - depending on your preferences for readable BPs π
lottta errrors
Interesting. Do you spawn your player manually?
ok so that might be part of the problem
It's ok if your gamemode needs to spawn the player a bit later.
π i just got that to working
I think for simplicity sake you could encapsulate your 'Update UI' function outside the player blueprint
into the instance instead?
Can your room manager access your UI directly?
i think so bc of the reference to player it has
You'll save yourself a lot of headaches if different BPs can talk to UI directly, without going through the player BP
i was gna say cast to the ui and get a ref inside the roommanager bp but would that be bad for framerate
Get UI shouldn't be a problem for CPU
If you want to optimize already, you could create a 'Get UI' function in your game instance and cache the return value in a variable.
so id make the cast and reference in a function inside my instance bp instead of casting inside the room bp itself?
i dont think i have my widget im using for hud setup as hud
got ya
ignore the Get HUD and get a reference to that widget instead, no problem
I assume the widget you spawn for clip count is cached in a variable somewhere?
wdym
only thing w spawning player is just the overwrittten fuinction in the game mode
Yeah normally if the player was spawned as soon as the level load, your room manager should be able to access it. But it doesn't seem to be the case at the moment because of all the errors you pasted earlier
Could you try something ? Instead of respawning a new player - can you just set its transform?
here:
when i did thst the player fell through the floor before
If we can fix the fact that the room manager has a null player reference, we'll be good
hmm - that might be an issue with transform. Maybe it's clipping through the floor collision?
they werent
ok - let's step back. Can you show me what is connected in the 'Update UI Count' function in the screenshot above? It was cropped
here:
And where do you set the value of this?
which seems to be a variable in the room manager BP
on begin play I assume?
seems to only be on the overlap
ok !
So I don't think you need to cache the player reference in a variable here.
Can you try replacing it with the native function get player character instead?
Rule of thumb - try to avoid caching the same actor reference in multiple BPs - it'll shield you from invalid references or value discrepancies
for the input on the update clipcounter funtion?
yep!
it wont let me connect them
you have to cast it to your BP Third Person Character class
ohh
you can right-click the cast and convert it to a 'pure' cast if you don't want the input/output
yea that works - and if you don't want to have to connect it - you can right-click the cast and convert to pure (all the way at the bottom)
great! now try to run it again
ok that's progress - there is no null ref to the player now
π i just saw wall of errors n thought shit were going backwards
can you click the first error 'Set Clip Count' and screenshot that function?
m'kay how about UpdateClipCounterUI?
small note - can you link 'self' in 'owning player' on the create player HUD widget?
or 'get player controller' if it doesn't work
cool cool. So is this the only place in the whole BP where the player HUD widget is created and assigned to the HUD var?
yea should be
can you try to add a breakpoint on both 'SET HUD' and 'UpdateClipCounterUI' and see which one fires first?
the update clip counter ui fucntion in the player or on the calling of the function in the room bp
here
this one hit
good - and the other one hits after? or doesn't hit at all
if i hit continue execution yea
ok interesting. So that's the core of the issue. You have room manager trying to do things before player is finished spawning & initializing stuff (including HUD)
If you don't want to change the player spawning override thing you did, I might have a suggestion
- Open Game Mode
- Create a new 'Event Dispatcher' called 'OnPlayerSpawned' or something
- In your Room Manager's begin play, bind to the Game Mode's 'OnPlayerSpawned' event and disconnect the rest.
- When you receive that event, execute everything you connected to 'BeginPlay' before.
And then in your game mode's player spawn overriden function, once the player pawn is spawned, call that event dispatcher
That should fix a number of these errors. The last one to fix will be the 'SaveGameRef' variable being null
I have to drive back home and I'll log back in in about an hour. Let me know how it goes!
sry my wifi cut out π
yeah that looks about right- did that fix the null HUD ref ?
now when overlapping the room bounds the ui dosnt update stays at 0, when collecting a clip it counts down from 0
dosnt update on load still either
Yep looks like we'll have a few more null refs to fix
I have to log off for today but if you want, we could hop on a channel and live debug it tomorrow ! Could be simpler than pasting screenshots π
sry i fell asleep my brain is friedππ but yea that sounds like a plan
Let me know what time works well for you today π
i may be able to closer to 1 today
in which timezone? π
πsry est
haha ok good. I'm EST too and I would have some time now
only thing i realized. my mic isnt workingπ
That's alright. Would you like to continue typing in thread or do you prefer sharing your screen but I'd be the only one talking? π
we could in the thread for a lil, im hopingπ atleast looking at the screenshot of the errors i had that the rest of whats making it not work is inside the clip pickup bps themselves so hopefully we are close to it workingπ
ah ok i see this is the room bp
yep - the room blueprint is an actor already dropped in the level right, you don't spawn it at runtime?
yea
ok. this is weird. So from what I remember from yesterday, you already set the game instance's save game variable before calling OpenLevel?
This LoadGame event is in the game instance?
yea is the function converted to an event
got it
if you add a 'Is Valid' check on the save game ref var right here, what does it return?
well, after the get game instance I guess
ah so it is valid.
It must be a different savegame var check that returns null
This one here - is that the begin play of the clip BP ?
yea
ok - and can you tell me the difference between what each clip does OnBeginPlay versus what the room manager does while looping through each clip?
room manager loops through them to get a count of what ones in level are linked to that room bp as the starting room bp
ah ok - got ya
I have a suggestion. Since the room BP is already doing 'Get all actors of class' and looping through them -- Can you try replacing the 'On Begin Play' from the Clip BP with a custom event called like Initialize or something
and then call that Initialize event from the room BP, in the foreach loop
this way, it will defer the save game var check until the player has spawned
It's still very odd since the save game var is normally set before the clip even spawns, but I want to double check if that's the cause of the error spam we're seeing
hmmm lemme try that
so remove the begin play stuff from the clip bp, replace w an event called initalize inside the event get the clips starting room ref and get the for each ?
yes for the first half, and then call the initialize on each clip in the room's foreach yup
I'm curious to see if it'll make a difference
im slightly confused π
Would you be willing to jump on a call even if no mic? I think we could save quite a bit of time π
yea
Cool cool - I'll join..... let's say Public Boole
kk
hi yea sry lol
π
it says i cant share it in this channel π
ehhh maybe just stick w the thread lol
kk
this is the clip bps variables and what i have sofar
You can replace the Begin Play with the Initialize Clip event - and connect everything there
ah ok
I see what you confused
the starting room is done on each instance i place in level
and then in the room BP:
this way the room takes care of initializing the clips
and this all happens after the player has spawned
Nice - let's see if that fixes the error spamming
it stopped the errors but now all the clips i collect respawn on load
ok good, one step at a time haha
and the count isnt updating is staying at 0 then counting down π
there's a lot of order of execution to clean up and regain control of
Now we have the level loading, the player spawning and the room fetching clips & initializing them.
Next step: set the clips' proper default state
kk
Could you edit the Clip BP so that the clips spawn invisible + No collision by default?
aside from the construction script? like just setting their visibility n stuff manually
Yea either settings on the components/actor or construction script- both would work
ah nice ok -
So in that case, Active? = false by default should do the trick
Now that this is done - you should spawn in the level with all clips turned off.
kk i made it false by default lemme check
Which is great - then the clips can check in the 'Initialize' event if it should activate itself based on save game data
yup all invisible
awesome
Now in the clip BP - in the Initialize event, you're already reading data from the save game ref var
If the ID of the clip is in the save game ID array, activate the clip!
Does this path reenable collisions & make visible?
it did at one point but now jus connects to setting the clips starting location
ok - you should bring it back
that would be the perfect spot to reactivate the clip
theyr still all hidden when loading in a level
can you try wiping save game and try again?
that was after hitting new game
ok
this means that one of these two arrays contains the clip ID
Since its a new game, it's probably not the save game array
can you breakpoint on the OR Branch and check the value of both arrays?
I like the pixelized rendering π
prolly should clear it here then since im only clearing the instance arrays not the save game array?
what's the default value of that array in the save game object?
no need to clear - your save game ref var is already null at that point
theres nothing in the default value for saved
ok and how about the game instance array - is it also empty?
yea
ok
add a breakpoint on that branch
and when it breaks, mouse over both arrays to check their content
something must be filling it up
its not breaking
nope only thing is a few errors
that's new. We can look at these later
do you have an instance selected in the clip BP dropdown? Maybe it can prevent breakpoint from working properly
either select none or select one in particular. Sometimes breakpoints are buggy with multiple instances of the same BP
this?
no this little dropdown :
ok good
Can you breakpoint on these in the room BP?
to see how many actors you find and if they foreach loop fine
they didnt break either
off the isvalid?
hmm let's say just print the display name of the BP in the InitializeClip event
oh I just realized something
In your screenshot, when you click New game - you delete the save game and call Open Level immediately after
but you don't re-create a new save game beforehand?
no
that's probably the reason why it doesn't reach the foreach loop
game instance's save game var ref is probably null
so have it save after loading the level?
Ideally, when you click new game it should:
- Delete old save file
- Create new Save Game object
- Update Game Instance save game var reference
- Async Save game
- Open level once save game is complete
I don't see how the change we did could affect the player at all
Is the spawn location of the player determined by data from the save game?
this is the only thing afecting the spawn
yep - now that we create the save game before loading the level, it becomes valid
ohh
so it should wait til level loads then save so its not vaild before they spawn?
Nah it's ok that this happens before level load
I would recommend a different check
Can you add a boolean in the save game class called 'Custom Player Transform' and set it to false by default?
This way - instead of checking if save game is valid - you could check the value of that boolean in the save game data
if false = spawn at Default Player start
if true = spawn at save game Transform
and when you save the game later on and save the player's position in the world, just set this bool to true
so jus use a normal branch
yea instead of the IsValid here:
ok you still need the IsValid check I guess
is valid would still branch to Default player start
they didnt spawn through the floor tho
if false
nice. Yeah you could have a double check here just to remove the error
Is valid, then branch
kk
ok! so are breakpoints still not hitting?
no
Alright - In the room BP - can you breakpoint on the playerspawned event?
and can you paste the event's blueprint graph again plz?
Does this ever hit?
no
lol ok - so it looks like the player is spawned before the binding happens
let's handle both cases
This is in the game mode BP right?
yea
ok - let's try this
before doing the bind here, in the room bp:
add a IsValid check on the player ref variable from GameMode BP
if Is Valid = true, call 'OnPlayerSpawn' event directly.
if Is Valid = false, bind to OnPlayerSpawned
the player ref variable is in the instance tho
yea thats from the instance
good. Check that one
if it's valid - it means the player is already spawned therefore we don't have to bind & wait for it to spawn
so cast to instance or promote instance to a varibale in the game mode n call it that way
No you can check the game instance var directly π
almost yea
so, if IsValid is true, call Onplayerspawns
if it's NOT valid, link to Bind Event
Also I think your As NH Main Game Instance var will be null here. You have to move up your Get Game Instance + Cast + Var caching OnBeginPLay
Nice
so now you should break everywhere
the for each loop, the initialize clip events, etc.
are the clips in the proper state?
they seem to, i think
but now when player loads it spawns them at player start instead of the saved transform again
Yep - that's because of the new boolean
In which blueprint do you save the current player's transform?
ahh
in the instance in the save function
ok! You have to set that boolean to true at that exact moment as well, before saving
nice. yep, right after that set transform
and if you collect a clip and reload the game, does the state work correctly?
seems to be
Sweet
So now we can attack the final boss - the counter on the screen
π yay were getting there lol
yes
Ok. Then it can either mean that 'Active room' is invalid OR that the remaining clip count check is buggy
Where do you set 'Active room' ?
ok - I would like to propose a slightly different ownership approach here.
For that function specifically
You could add an input (integer) to that function - and link it direclty in SetClipCount
no need to fetch Active Room at all. The function would just get told what to set
yea - remove the active room valid check too! let's keep it lean
alright
Now, in the room BP - link the proper var in the 'UpdateClipCounterUI' call
Eventually, when you have multiple room BPs, you'll probably have to check if this room is active before calling the UpdateUI function
so quick question to understand the intention here
Is the counter supposed to only display how many clips are inside that specific room you just stepped in?
yea
ok
in that screenshot you just posted - remaining clip count is a variable that also exists in the player bp?
or is that in the room BP as well
thats in the room bp
ah nice
ok wonderful
does your room have a 'Is Active' boolean state too?
I'm thinking that it probably should have one.
This way you could add a 'Is Active' branch right here:
To make sure that all rooms don't update the counter UI all at once when the level starts
That brings me another question -- is the player always inside a room? Or is it possible for the player to be outside ALL the room triggers and be in ZERO room?
Hmm I'm thinking out loud here - but even if that was the case, that wouldn't be a problem since the count would be 0 and that would be OK π
so.. let's see
Yep that would be the only last thing to do.
- Create a 'Is Room Active' boolean (false by default)
- Set that bool to true OnOverlapBegin and false OnOverlapEnd
- Branch check that boolean before the 'UpdateClipCounterUI' connected to the foreach completed
just for safety
the rest should work !
There might be one last issue with players spawning inside a room and not firing the Overlap Event, we can fix that after.
ive been meaning to add one just save and load bugs have been the main focus last few days
yea bc the menu and character selects are levels without rooms as well and the player is set to spawn at the start in them and i put a box of inviswalls around it
nice ok - in which case the counter would display 0 (or would be hidden) so I guess there's no additional needs there
loading into the room after saving the ui stays at 0
but other than that it seems to be working
excellent
as expected, the cursed player in trigger bug
So here's a suggestion for how we could go about it
In the room BP's construction script, disable collisions on the trigger volume
then, in the event 'Onplayerspawns' (which guarantees that the player is spawned), enable collisions on the trigger
hopefully this will trigger the overlap event
that didnt seem to change it
ok.
Quick question
when you spawn inside a room - if you leave that room, does the Overlap End event fire?
yea
nice ok
then let's use Plan B
you can delete the construction script stuff we just did
kk
In the room BP, create a new function called 'Is Player In Room'
is your room trigger always a box?
yea
awesome
In that function - check if the player pawn position is inside the box trigger component
thanks !
Create a custom event and link it at the same place than OnBeginOverlap
something like 'OnPlayerEnteredRoom' or something
nice
and finally:
in the room BP still, when you're done initializing clips-
Check if player is in room, branch the output result - and if it's TRUE, call the OnPlayerEntersRoom event
technically, you will be able to delete that UpdateCounterUI call too, since the new event will take care of it
nice yep!
You can test it like that, but if it works, I would recommend removing these and testing again:
π€
or do i not need the room active check anymore
oh right
yea you can remove it most likely
the IsPlayerInRoom is the equivalent in this case, only checked once, but ensures that the player is indeed in the room
and calling that event will set IsActive to true
so yeah you can delete it
on load the ui is still at 0
you can breakpoint on the branch after Is Player In Room function to check the output value when testing
curious if the function works as expected
it hit right as the level loads
can you mouse over the output of the function? (PLayer in room?)
does it say true or false
false
ok!
inside that Is Player in Room? function - can you breakpoint on its return node ?
let's check the values of 'player position' versus 'box location & box extent'
I suspect it might be related to the player controller vs player pawn
Did you setup your player controller to follow the player pawn or not?
it hit on level loading just like the branch
good good, mouse over the player controller location pls π
if its 0,0,0, then that will be an easy fix
hmmm - how about the box world location?
yea
ok
Something interesting though
They have the same Z
Can you try getting the pawn's location instead of the controller?
I think the controller is placed at the root of the capsule - and the pawn's location is right in the middle of the capsule, which is better for trigger checks
yea
can you mouse over the scaled extent?
try unscaled box extent
kk
could it be the box collision isnt default scale before being placedin a level i edited the scale in the bp and in level
That should be ok - that's what the 'Scaled box extent' is for usually
oh
there's something that bothers me with the maths though
Your screenshots say that the player is at x = 2430 , and that the trigger box is at x = 190 with an x extent of 540
so based on maths alone - the player is indeed outside the trigger
yea bc im clicking new game
ohh
oh ok - I thought you were sending screenshot of the locations & extent when the player spawns inside a trigger
ohh sry
lol
np
so then, you can remove all breakpoints
and you can place a single breakpoint on the custom event you added above the Beginoverlap
lets check if that one breaks when you load directly in a room
didnt break when loading into a room
and what are the locations & extent of the box & player when loading directly in a room?
ok lets try modifying the 'is player in room' function
kk
no is still 0 until player exits and re enters the room bounds
interesting ok
let's add a breakpoint on the UpdateUI function later after the OnPLayerEnterRoom event is called
I'm trying to scroll up to see the whole scripting chain
only see it partially
ok - can you paste the whole script connected to OnPlayerEntersRoom event?
ohh wow ok
omg lol
ok nvm I know why haha
That custom event shouldn't try to read the 'Other Actor' value of the begin overlap event :d
π
ahh
instead, you can get player pawn, cast to BP_ThirdPerson, set var value and link to 'Set room name'
ok
HUD seems null interesting
can you open the player BP and show where HUD is set?
ok - begin play order of execution conflict
Let's do something in the player BP
Create a new function called 'Get Player HUD'
Select the function and set it as 'Pure'
Inside the function:
then, replace this with that function you just created
And finally, in the room BP, replace all the 'Get Character > HUD var' with 'Get Character > Get Player HUD'
To make sure this doesn't happen to you again somewhere else, you can set the HUD var to 'Private' in the player BP
kk lemme try
this way no external BP can read the variable value - but the getter is public and makes sure that the widget always exists
Honestly I think you had the right approach for a lot of this stuff.
But when you have several actors spawning / initializing stuff on begin play and cross referencing each other, Unreal isn't good at controlling order of execution (which actor fires OnBeginPlay first)
So deferring initialization to managers or important blueprints + creating safe getters like the one we just did usually works out
looks good - how about your Get Player HUD function?
ahh
Nice nice -
let's take it for a spin π€
there's the Set Clip Count in Update UI function that you also might have to replace
seems to be working π€
π₯³
I hope the modifications we did throughout the afternoon make sense for you and work well for your project π
ty that did make sense i was fully just troubleshooting in circles before this lol
me too i rly appreciate it
Have fun and I'll be looking forward to see your game progress!
Any socials where I can follow your game updates?
not sure quite yet im workking w a few other people im mostly doing the programming/game design and asset porting from blender to unreal but were making the game as a surprise to somee content creators so we havent rly decided on where to post yet aside form i think itch.io
ty you too w your projects
thanks! π yeah, shipping soon - I'm gonna need all the positive vibes I can get
quick question π i noticed a bug when loading in a build. if i quit out of the game then click load it acts as if theres not a save file,
Is there something setting the value of Save Game Ref variable to null when quitting back to main menu?
i dont think so
but it only seems to happen if quit game is used, but the save file exists i can see it in the folder for the build
also randomly if the player's z value is high the room/ui acts like the player exits rq and re enters
i think that mayve just been an issue w how i had the room bp placed bc it fixed itself afaik
That is strange indeed for the save. But the save game object at runtime and the actual save file on disk are two different things
So are you saying that this returns invalid?
yea im pretty sure that was the one that was printing since i added that as a check so the player couldnt load into a level if there isnt a save
You can try to search in all blueprints if there's something else resetting the value of that 'save game ref' variable