PreBeginPlay v.s. PostBeginPlay - Noob questions

Discussions about Coding and Scripting

PreBeginPlay v.s. PostBeginPlay - Noob questions

Postby MrLoathsome » Sat Mar 16, 2013 5:16 am

Scenario. I have been working on a mutator, that has had a considerable amount of processing going on in
the PostBeginPlay function. All has been well.

Decided to add 2 statements to the initialization for the mutator that needed to be in PreBeginPlay.

So I just stuck them into the existing PostBeginPlay and renamed it to PreBeginPlay.

All the stuff I had in PostBeginPlay before seems to work fine in either function.

My noobish questions:

Would there be any performance advantage if I moved the bulk of the code that works fine in either
function back into PostBeginPlay?
Does this cause some problem I haven't discovered yet? Or is it ok just to leave it all in PreBeginPlay?
Download my stuff here: http://ecoop.tk/load/
MrLoathsome
Adept
 
Posts: 498
Joined: Wed Mar 31, 2010 3:02 pm
Personal rank: Mooooo !

Re: PreBeginPlay v.s. PostBeginPlay - Noob questions

Postby Feralidragon » Sat Mar 16, 2013 7:08 am

The only difference between Post and Pre, besides the order they are called, is that in Pre the zone info was not set yet for the actor, and the encroachment check was not made yet either.
You can see this info here: http://wiki.beyondunreal.com/Legacy:Cha ... s#...in_UT

There's no difference in performance, it's mostly if it's important or not process something before or after the events between Pre and Post.
( I am no longer active around here, so I won't respond to any PMs, thus if you wish to contact me, do so in ModDB/IndieDB or by email )
Image
Nali Weapons 3 | Community UT mods
User avatar
Feralidragon
Godlike
 
Posts: 4630
Joined: Wed Feb 27, 2008 12:24 pm
Location: Portugal - Lisbon
Personal rank: -- RETIRED --

Re: PreBeginPlay v.s. PostBeginPlay - Noob questions

Postby Higor » Sat Mar 16, 2013 12:29 pm

If you destroy an actor in PreBeginPlay(), BeginPlay() isn't called.
If you destroy an actor in or before BeginPlay(), PostBeginPlay() isn't called.

PreBeginPlay() has a general definition in all actors which allows them to be 'mutated', an actor with an overriden PreBeginPlay() without a Super.PreBeginPlay() call inside will not be affected by mutators, which isn't necessarily a good thing.
Higor
Masterful
 
Posts: 735
Joined: Sun Mar 04, 2012 12:47 pm

Re: PreBeginPlay v.s. PostBeginPlay - Noob questions

Postby MrLoathsome » Sat Mar 16, 2013 10:58 pm

Thanks to both of you for the replies. Exactly the info I needed.

Some of the processing I got in there does indeed reference .Region.Zone info.

I am going to separate things, and have a short PreBeginPlay, and larger PostBeginPlay.
Both will have a call to Super in them.

That will be the best way I think, and make the code look a bit nicer.

Edit---

While I have your attention.... One of the things I want to do is have the mutator
unload itself right away, if the gametype is Assault.
Here are the 1st two lines in my current PreBeginPlay() function:
Code: Select all
   Super.PreBeginPlay();
   If (Level.Game.IsA('Assault')) { Self.Destroy(); return; }


That seems to work perfect, but figured I might as well check with you guys to
see if there is a better way, or if that causes some problems I haven't yet encountered
in testing.
Download my stuff here: http://ecoop.tk/load/
MrLoathsome
Adept
 
Posts: 498
Joined: Wed Mar 31, 2010 3:02 pm
Personal rank: Mooooo !


Return to Coding, Scripting

Who is online

Users browsing this forum: LannFyre and 0 guests