Hello Guest

Author Topic: After adding a trail renderer to tk2dspriteanimator it is destroyed  (Read 4340 times)

ryanjnauman

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 2
    • View Profile
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?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: After adding a trail renderer to tk2dspriteanimator it is destroyed
« Reply #1 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.

ryanjnauman

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: After adding a trail renderer to tk2dspriteanimator it is destroyed
« Reply #2 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!