2D Toolkit Forum

2D Toolkit => Support => Topic started by: ryanjnauman on March 15, 2014, 12:18:41 pm

Title: After adding a trail renderer to tk2dspriteanimator it is destroyed
Post by: ryanjnauman on March 15, 2014, 12:18:41 pm
I created a tk2dspriteanimator that I am moving around the screen. I added a trail renderer component to it which works fine until after I've moved my sprite and then stopped moving. It throws MissingReferenceException: The object of type 'tk2dSpriteAnimator' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.

I'm new so if this is obvious I'm not sure. Any ideas?
Title: Re: After adding a trail renderer to tk2dspriteanimator it is destroyed
Post by: unikronsoftware on March 15, 2014, 01:02:07 pm
You should try and work out why its getting destroyed. Set a breakpoint in the debugger in OnDestroy (add a blank function with a Debug.Log in tk2dSpriteAnimator) and see when it hits it. The component must be getting deleted somehow, eg. autodestruct or something. No idea how you have it configured on yours.
Title: Re: After adding a trail renderer to tk2dspriteanimator it is destroyed
Post by: ryanjnauman on March 24, 2014, 05:01:29 pm
It turns out that the trail renderer's autodestruct option was on. This was the problem. Even with that component unchecked, it was still destroying my sprite. Only after I removed the trail renderer or unchecked autodestruct did things go back to normal. I would never have seen this if you didn't mention autodestruct. Thanks!