@Chosker
After some testing, it looks like you were right about the package taking some time to load. I appear to have been mistaken as to the nature of DynamicLoadObject, in that it performs a non-blocking load (i.e initiates loading but returns immediately rather than waiting). This makes sense, now that I think about it, given the fact that you wouldn't want pauses for content loading in the middle of a deathmatch, say.
Ordinarily I'd not have a problem with simply waiting and trying to use the content after a slight delay, but given this is dialogue any pause long enough to absolutely guarantee content is fully loaded would be noticeable and not really desirable.
Bearing my discovery in mind, my new question is this: Does anybody know of a decent way to ensure that the appropriate package is loaded far enough in advance for my call to DynamicLoadObject/PlaySound to succeed, but without introducing unacceptable delays between the player initiating conversation and the audio playing?
I could have each NPC load the package containing their dialogue data in PostBeginPlay() or defaultproperties but the number of NPCs would make this consume too much memory I think.
Alternatively I could load the package containing NPC dialogue based on NPC proximity to the player, but the problem of memory consumption remains insofar as if the player simply walks past a number of NPCs they would inadvertently trigger the loading of a number of packages, whether they be used (through conversation being initiated) or not. Is this a concern? Will the engine intelligently unload those packages again if they aren't actually being referenced, or will they stay in memory until the level transitions?
Feel free to move this post back into the general forum if it would be more appropriate there.
Original post is as follows:
My understanding of DynamicLoadObject is that it will load packages required before attempting to instantiate the requested class.
Unfortunately, when I attempt to use it to instantiate a SoundCue like so:
It fails to load - nothing happens.
params.SoundBite is a string.
On the other hand,
works without any issues.
I've resolved this temporarily by putting a hardcoded reference to an object in the package in defaultproperties (which evidently forces the package to be loaded automatically, and therefore DynamicLoadObject succeeds), but my understanding was that the entire point of DynamicLoadObject vs FindObject is that DynamicLoadObject would load the package if it had to. This behaviour seems to not reflect that.
I'm using the 32-bit build of the May 2012 UDK.
After some testing, it looks like you were right about the package taking some time to load. I appear to have been mistaken as to the nature of DynamicLoadObject, in that it performs a non-blocking load (i.e initiates loading but returns immediately rather than waiting). This makes sense, now that I think about it, given the fact that you wouldn't want pauses for content loading in the middle of a deathmatch, say.
Ordinarily I'd not have a problem with simply waiting and trying to use the content after a slight delay, but given this is dialogue any pause long enough to absolutely guarantee content is fully loaded would be noticeable and not really desirable.
Bearing my discovery in mind, my new question is this: Does anybody know of a decent way to ensure that the appropriate package is loaded far enough in advance for my call to DynamicLoadObject/PlaySound to succeed, but without introducing unacceptable delays between the player initiating conversation and the audio playing?
I could have each NPC load the package containing their dialogue data in PostBeginPlay() or defaultproperties but the number of NPCs would make this consume too much memory I think.
Alternatively I could load the package containing NPC dialogue based on NPC proximity to the player, but the problem of memory consumption remains insofar as if the player simply walks past a number of NPCs they would inadvertently trigger the loading of a number of packages, whether they be used (through conversation being initiated) or not. Is this a concern? Will the engine intelligently unload those packages again if they aren't actually being referenced, or will they stay in memory until the level transitions?
Feel free to move this post back into the general forum if it would be more appropriate there.
Original post is as follows:
My understanding of DynamicLoadObject is that it will load packages required before attempting to instantiate the requested class.
Unfortunately, when I attempt to use it to instantiate a SoundCue like so:
Code:
SoundToPlay = SoundCue(DynamicLoadObject(params.SoundBite, class'SoundCue')); GetPC().Pawn.PlaySound(SoundToPlay);
params.SoundBite is a string.
On the other hand,
Code:
GetPC().Pawn.PlaySound(SoundCue'EFPL_Cafe_Dialogue.barista_01_Cue');
I've resolved this temporarily by putting a hardcoded reference to an object in the package in defaultproperties (which evidently forces the package to be loaded automatically, and therefore DynamicLoadObject succeeds), but my understanding was that the entire point of DynamicLoadObject vs FindObject is that DynamicLoadObject would load the package if it had to. This behaviour seems to not reflect that.
I'm using the 32-bit build of the May 2012 UDK.
Comment