playMaker

Author Topic: Create Object Glitch  (Read 158 times)

Kodagames

  • Playmaker Newbie
  • *
  • Posts: 30
    • View Profile
    • KodaGames
Create Object Glitch
« 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?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 3664
    • View Profile
    • jinxtergames
Re: Create Object Glitch
« Reply #1 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 called Pooler.

krmko

  • Beta Group
  • Hero Member
  • *
  • Posts: 847
    • View Profile
    • Fat Pug Studio
Re: Create Object Glitch
« Reply #2 on: November 11, 2018, 02:58:21 PM »
Instantiation is one of the most expensive functions in the engine, try avoiding it.

Kodagames

  • Playmaker Newbie
  • *
  • Posts: 30
    • View Profile
    • KodaGames
Re: Create Object Glitch
« Reply #3 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
 

Kodagames

  • Playmaker Newbie
  • *
  • Posts: 30
    • View Profile
    • KodaGames
Re: Create Object Glitch
« Reply #4 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.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 13635
  • Official Playmaker Support
    • View Profile
Re: Create Object Glitch
« Reply #5 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