Lua Codes slows down game in cutscenes
Posted: Fri Nov 19, 2021 6:47 am
Hey there, I use the sequence functions quite a lot in my game to generate cutscenes.
This can look like this:
The issue is that this leads to some very long frame times on certain occasions during this sequence. Especially on Nintendo Switch. My levels are quite big and can contain thousands of game objects. So I guess the heavy usage of "find by name" leads to this problem. I tried to use the direct path [LEVEL_ARCHITECTURE/LEV_ELEM_00a/PLAYGROUND/SEQUENCES/Soldier_Sequence_Start/Actors/Balloon00] to the game object to ease this issue. This helps a bit but does not solve it entirely and it would consume an extreme amount of time to go through all the conversations and find all the direct paths to every game object.
So, I was thinking about if there is a way to find all the objects on start so all the assignments would happen when the level is loaded and not at the very frame the object is needed.
Any help is appreciated.
This can look like this:
Code: Select all
AnimatorPlay(WALK_S, LEVEL_ARCHITECTURE/LEV_ELEM_00a/PLAYGROUND/SEQUENCES/Soldier_Sequence_Start/Actors/Female_Soldier/Female_Soldier_Sprite); MoveTo(WP_Plant, Female_Soldier, 1.75); AnimatorPlay(ATTACK, Female_Soldier_Sprite)@1.75; AnimatorPlay(ATTACK, Female_Soldier_Sprite)@2.25; SetActive(LEVEL_ARCHITECTURE/LEV_ELEM_00a/PLAYGROUND/SEQUENCES/Soldier_Sequence_Start/Actors/Ballon_Pop_effect_cs, true)@2.5; SetActive(LEVEL_ARCHITECTURE/LEV_ELEM_00a/PLAYGROUND/SEQUENCES/Soldier_Sequence_Start/Actors/Balloon00, true)@2.75; Parent(LEVEL_ARCHITECTURE/LEV_ELEM_00a/PLAYGROUND/SEQUENCES/Soldier_Sequence_Start/Actors/Female_Soldier, LEVEL_ARCHITECTURE/LEV_ELEM_00a/PLAYGROUND/SEQUENCES/Soldier_Sequence_Start/Actors/Balloon00, true)@3.5; AnimatorPlay(HANG2BALLON, LEVEL_ARCHITECTURE/LEV_ELEM_00a/PLAYGROUND/SEQUENCES/Soldier_Sequence_Start/Actors/Female_Soldier/Female_Soldier_Sprite)@3; MoveTo(WP_Plant, Sargent, 1)@5; MoveTo(WP_Plant, Male_Soldier, 1)@4.5; AnimatorPlay(WALK, Sargent, 1)@4.5; AnimatorPlay(WALK, Male_Soldier, 1)@4.5; FlipObject(Sargent_Sprite)@4.5; CustomFader(ScreenBlackOutIn, 2, 1)@5; required GoToNextCinTarget(CameraSequence)@6; SendMessage(StopConversation,,Play_SpecialMovement)@7; required PersistentSetActive(Soldier_Sequence_Start, false)@8; Continue()@7.1; required SetActive(JS_sfx_rescue_begins_rope_snap, true)@2.5; required SetActive(JS_mus_rescue_begins_ducks_volume, false)@8;
So, I was thinking about if there is a way to find all the objects on start so all the assignments would happen when the level is loaded and not at the very frame the object is needed.
Any help is appreciated.