When starting a new game from the menu the custom PlayerPawn calls BeginPlay() and PostBeginPlay() correctly. (see console)
But when starting another lever (in the example level, by pulling the switch) the custom PlayerPawn calls BeginPlay() twice and doesn't even call PostBeginPlay() once! (see console)
Additional info:
- the console command "map *" works correctly (BeginPlay() and PostBeginPlay() called), but "changemap *" doesn't (BeginPlay() called twice)
- problem only exists in PlayerPawn (as far as I'm aware)
Provided in this .zip-file:
- ZScript PlayerPawn definition
- MapInfo definition for test level
- test level for proof
I'm using GZDoom 4.10.0 and ZScript 4.10.0
PostBeginPlay() doesn't get called in certain situations
Moderator: GZDoom Developers
Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
-
- Posts: 12
- Joined: Wed Jun 01, 2022 3:46 am
- Location: ZScript purgatory
PostBeginPlay() doesn't get called in certain situations
You do not have the required permissions to view the files attached to this post.
-
- Lead GZDoom+Raze Developer
- Posts: 49140
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: PostBeginPlay() doesn't get called in certain situations
This is because the freshly spawned PlayerPawn is not kept around. Your original player from the previous level will take over and the new ones be destroyed before PostBeginPlay is ever reached
-
- Posts: 12
- Joined: Wed Jun 01, 2022 3:46 am
- Location: ZScript purgatory
Re: PostBeginPlay() doesn't get called in certain situations
So the newly spawned PlayerPawn and the player carried over from the previous level both call BeginPlay but neither of them call PostBeginPlay?
-
- Lead GZDoom+Raze Developer
- Posts: 49140
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: PostBeginPlay() doesn't get called in certain situations
No, the original player does not call BeginPlay. The engine spawns two new players on the new map and ultimately destroys both of them again.
You cannot rely on these two functions for players.
You cannot rely on these two functions for players.
-
-
- Posts: 17455
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: PostBeginPlay() doesn't get called in certain situations
Use the PlayerSpawned and/or PlayerEntered to reliably run code on player actors.
https://zdoom.org/wiki/Events_and_handlers
https://zdoom.org/wiki/Events_and_handlers