Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Fat Pug Studio on March 04, 2018, 04:11:28 PM

Title: Problem with Animator and Pooling
Post by: Fat Pug Studio on March 04, 2018, 04:11:28 PM
Hello guys,

I'm using pooling for my objects, and most of them have animator. I encountered problems with pooling before, i didn't know that i'm supposed to reset variables, but one problem persists.

Before despawning, to make sure all is tidied up, i set the object animator to idle state (which has no exit time), disable the component and then disable the object, so the animator should start fresh from the idle state and wait for the action trigger to start the desired state in the animator.

BUT, when object is respawned, the animator frame in which the animation stopped is set as the sprite renderer sprite. I tried sorting this out by making texture hashtable and the object fetching the texture converting it to sprite and setting it as sprite in sprite renderer since i can't get sprite from hash table, even though i can hold it there.

But i get a bunch of errors and unwanted behaviour when i fetch the texture from hashtable and convert it to sprite, and besides, i don't know how convenient is to actually convert the texture everytime the object spawns. Sure, i could just use set sprite and drag the texture from the project, but i like to work with references to ensure everything is ok in the build tomorrow.