playMaker

Author Topic: Create Object Performance Issue  (Read 867 times)

Starside

  • Playmaker Newbie
  • *
  • Posts: 8
Create Object Performance Issue
« on: January 07, 2022, 02:43:13 PM »
Hello. Im trying to spawn my Invector FSM AI by using "Create Object" but get massive lag spikes when I try. Any ideas?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Create Object Performance Issue
« Reply #1 on: January 07, 2022, 02:56:06 PM »
Hi.
Create/destroy objects during gameplay is indeed heavy.

You can create on loading a scene and disable, then enable/disable when needed.
or if it is reusable then you might want to look into pooling.

Starside

  • Playmaker Newbie
  • *
  • Posts: 8
Re: Create Object Performance Issue
« Reply #2 on: January 07, 2022, 03:14:51 PM »
Gotcha. Yeah I am trying to spawn in enemies to create a wave like system. I have tried pooling, but even activating enemies still causes a spike. Here is an image. Drops from 60 to 50 FPS with a stutter

« Last Edit: January 07, 2022, 03:32:43 PM by Starside »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Create Object Performance Issue
« Reply #3 on: January 07, 2022, 09:07:20 PM »
Hi.
You should try testing in a build as in the unity editor the playmaker editor tool is also active.
https://docs.unity3d.com/Manual/profiler-profiling-applications.html

how are they detecting the player?
do they use raycasts every frame for example.
Does the enemies have a lot of Get/Set Properties actions.

in our game i had issues with it and reduced lag pikes a lot when not checking every frame (every 4-5 frames and only when player is near, to see when player is near i check the distance for example)

also try some test like disabling most components/fsm.

if you google for example "unity spawn multiple enemies lagging"
you will find several posts (unity/reddit/etc.) on this topic.

Starside

  • Playmaker Newbie
  • *
  • Posts: 8
Re: Create Object Performance Issue
« Reply #4 on: January 07, 2022, 09:13:39 PM »
This is in a build. The enemy AI is invector. So the only Playmaker FSM is the one spawning in the enemies (the one seen in the video). The profiler is suggesting that Playmaker is causing this issue correct?
« Last Edit: January 07, 2022, 09:16:15 PM by Starside »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Create Object Performance Issue
« Reply #5 on: January 07, 2022, 10:32:32 PM »
Hi.
Well, for example on the image you can see that inside playmaker update 22% is from instantiate.
Which comes from instantiate actions.
But you would have this also if you would use instantiate outside playmaker.

To activate then, you can try to set the state in sequence (right click empty space in the action window) it might help.

in our game we use lean pool, but on the Ecosystem you can also find Pooler Pool

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Create Object Performance Issue
« Reply #6 on: January 07, 2022, 10:38:19 PM »
Hi.
Just after posting i noticed on your video that on the profiler it is doing some instantiate

also try to disable recursively.

Starside

  • Playmaker Newbie
  • *
  • Posts: 8
Re: Create Object Performance Issue
« Reply #7 on: January 07, 2022, 11:19:32 PM »
Where do I disable that? Appreciate the help

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Create Object Performance Issue
« Reply #8 on: January 08, 2022, 10:02:54 AM »
Hi.
on the Activate Game Object action.