Playmaker Forum

Playmaker Help & Tips => Playmaker Help => Topic started by: Kodagames on November 11, 2018, 12:04:30 PM

Title: Create Object Glitch
Post by: Kodagames on November 11, 2018, 12:04:30 PM
Hello,

I'm noticing a type of glitch when creating an object (spawning) and was wondering if anyone has had similar experiences.

Each time an object is spawned the ones previously spawned will stutter (for lack of a better word or pause movement for a brief split second when another one is created).

A very simple setup.
Start State: Create Object, Transition Finished 
Wait For Next: Random Wait, Finish Event : Finished (Goes bak to the start state)
The Prefab Im spawning has a translate -2 in the X direction (different FSM).

Any suggestions on figuring out how to remove the Flicker when a new prefab is created? or why it may be happening?
Title: Re: Create Object Glitch
Post by: djaydino on November 11, 2018, 02:52:41 PM
Hi.
If you are spawning many object, you might want to use pooling.
Create/destroy are expensive(cpu)

A pooler will spawn a preset amount of object (best at the start of the game) and then activate when needed.
When deactivate they go back in the list so the can be reused later.

There is a simple pooling system package  on the Ecosystem (https://hutonggames.fogbugz.com/default.asp?W1181) called Pooler.
Title: Re: Create Object Glitch
Post by: krmko on November 11, 2018, 02:58:21 PM
Instantiation is one of the most expensive functions in the engine, try avoiding it.
Title: Re: Create Object Glitch
Post by: Kodagames on November 11, 2018, 03:12:41 PM
I do intend to use pooling but when starting a new game I like to use create object to prototype first ;) but this time I got this strange effect.

It must have something to do with the collider because when I click Is Trigger the glitch effect is gone which is strange (thinking of scenarios when I need enemies with colliders, maybe it would be different if the collier is a child?). Anyway problem solved if cloudier is a trigger.

Appreciate the feedback on Pooling :D
 
Title: Re: Create Object Glitch
Post by: Kodagames on November 11, 2018, 04:06:26 PM
So the Is Trigger, or collider is not the issue, I removed the random wait and used the regular wait action and vice versa and believe this is where the glitch is coming from, how I have no idea...

Is there another way to create multiple objects without using the "Wait or Random Wait" I'm currently having them spawn every 1 to 2 seconds.
Title: Re: Create Object Glitch
Post by: jeanfabre on November 11, 2018, 11:13:54 PM
Hi,

 you'll need to profile, it's likely something in your prefab start routine, or maybe some assets that takes time to decompress ( like sound or texture)

Bye,

 Jean