playMaker

Author Topic: Regarding level loading and preloading  (Read 571 times)

Evaldas

  • Playmaker Newbie
  • *
  • Posts: 21
Regarding level loading and preloading
« on: March 30, 2021, 12:35:19 PM »
Hi everyone!

I am making my second game totally with playmaker and wanting to make it better that the first. My question - is there a best way to go about loading levels/objects/prefabs etc. at the start of the level? Until now I was simply using "Load level" action.

In my first game, which used enemy prefabs, I had a problem, that the level loads fine, but then on the first enemy spawn the game lags for a second (seems like it's loading the prefab), but on the all next spawns there's no lag.
I've tried looking up how to fix this but could not find a solution that worked - in unity settings the setting to preload that enemy prefab at game start did not help.

Also, at the start of the level, sometimes some of the FSM did not get some objects, for example, using "Get Game Object" action, making some game systems not work properly. I put some of the game system managing FSMs on wait action for 1-2 seconds at the start and then the "Get Game Object" worked.

So it seems there's some sort of importance to the order of loading FSMs and prefabs to avoid the bugs and make the game smoother, but I can't figure it out. Maybe because I have absolutely no programming background and it's something obvious? Maybe I should always put game initialising FSMs on wait at the start of the game?

Maybe somebody can guide me into the right direction? :)

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Regarding level loading and preloading
« Reply #1 on: March 30, 2021, 07:49:53 PM »
Hi.
Creating / Destroying is 'expensive'
You should use pooling or create @start from a scene.

Avoid raycasting every frame.

limit trigger event.
For example if you would have some coins that you can pick up, you could have a trigger event on the coins.
But its more efficient to have use for example a box cast on the player that can detect the coins. also the boxcast you can set like every 4 frames instead of every frame.

Evaldas

  • Playmaker Newbie
  • *
  • Posts: 21
Re: Regarding level loading and preloading
« Reply #2 on: March 31, 2021, 01:09:08 PM »
Thank you very much for the info, I will look into it!

If somebody have any other tips they are more than welcome!