Hello Guest

Author Topic: Error Msg: IndexOutofRangeException  (Read 4869 times)

BusterTFuzz

  • Newbie
  • *
  • Posts: 4
    • View Profile
Error Msg: IndexOutofRangeException
« on: August 20, 2013, 03:18:48 am »
Hi everyone,

I am relatively new to 2D Toolkit and Unity. I recently ran into a an issue when I began working on my currently project. I think I am missing something straightforward. Any insight would help.

(1) I added both an animated and non-animated sprite to my project
(2) I keep getting the same exception: IndexOutOfRangeException
(3) this exception occurs in tk2BaseSprite.UpdateCollider line 478

My guess is that I either don't something set somewhere in the sprite.
I have tried tracking this down. I imagine this is something simple and someone has seen this before.
Did I miss a parameter somewhere?

Thank you in advance

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Error Msg: IndexOutofRangeException
« Reply #1 on: August 20, 2013, 11:30:14 am »
Lookng at the code at line 478 (in version 2.1) it looks like the only way this could fail is if the sprite collection isn't committed correctly. Can you try committing it again to see if it improves things?

BusterTFuzz

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Error Msg: IndexOutofRangeException
« Reply #2 on: August 20, 2013, 05:40:58 pm »
I tried re-committing the Sprite Collection from which the sprite takes its frames from, but that made no difference. Here is some more information on the problem:

a) The sprite that seems to be the culprit is an animated sprite with 2 frames of animation.
b) I went into the class file that was causing the exception and I printed out some logging:

013-08-20 09:23:54,541 [5856] DEBUG tk2dBaseSprite - Player SpriteSprite_Alien_1_Frame_2
2013-08-20 09:23:54,543 [5856] DEBUG tk2dBaseSprite - boxCollder AnimatedSprite (UnityEngine.BoxCollider)
2013-08-20 09:23:54,545 [5856] DEBUG tk2dBaseSprite - Collider type: AnimatedSprite (UnityEngine.BoxCollider)
2013-08-20 09:23:54,547 [5856] DEBUG tk2dBaseSprite - Sprite Collider Vertices Length:2
2013-08-20 09:23:54,549 [5856] DEBUG tk2dBaseSprite - Sprite vertex
  • 35 21.5

2013-08-20 09:23:54,551 [5856] DEBUG tk2dBaseSprite - Sprite vertex [1] 32 17.5

08-20 09:23:54,877 [5856] DEBUG tk2dBaseSprite - Player SpriteSprite_Alien_1_Frame_1
2013-08-20 09:23:54,879 [5856] DEBUG tk2dBaseSprite - boxCollder AnimatedSprite (UnityEngine.BoxCollider)
2013-08-20 09:23:54,882 [5856] DEBUG tk2dBaseSprite - Collider type: AnimatedSprite (UnityEngine.BoxCollider)
2013-08-20 09:23:54,884 [5856] DEBUG tk2dBaseSprite - Sprite Collider Vertices Length:2
2013-08-20 09:23:54,886 [5856] DEBUG tk2dBaseSprite - Sprite vertex
  • 35 22.5

2013-08-20 09:23:54,888 [5856] DEBUG tk2dBaseSprite - Sprite vertex [1] 33 20.5

c) I ran the integrity check and it passed.
d) I tried rebuilding the indexes,and there were no errors.
e) The problem occurs before the game plays in the desktop player. Once the game plays there are no errors. It seems to happen upon initialization or the build process.

I am trying to narrow down the sprite that may be causing the exception. So far, this is the only sprite that shows up in the logging. I have 4 sprites on the screen. Only one is animated.

Thanks again.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Error Msg: IndexOutofRangeException
« Reply #3 on: August 20, 2013, 07:07:22 pm »
Can you isolate this and create a repro case for me? It will make this a lot easier to track down.

BusterTFuzz

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Error Msg: IndexOutofRangeException
« Reply #4 on: August 20, 2013, 07:14:44 pm »
I could zip up the entire project. I would need a place to deposit it.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Error Msg: IndexOutofRangeException
« Reply #5 on: August 20, 2013, 07:18:36 pm »
Instead of zipping up the entire project, could you strip it down a bit before doing that to reduce size. Also, if you're not using meta files, turn that on and you can just skip the libraries folder from the zip, and reduce it even further. If you get it down to a sensible size (20mb or so), you could post it in the private support forum... Otherwise put it on dropbox or something and email a link to support at unikronsoftware dot com.

BusterTFuzz

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Error Msg: IndexOutofRangeException
« Reply #6 on: August 20, 2013, 08:05:36 pm »
I believe I have solved it. I attached a rigid body to the sprite and question and the error/exception went away.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Error Msg: IndexOutofRangeException
« Reply #7 on: August 21, 2013, 11:26:45 am »
Hi,
Glad you've got it solved but that doesn't really explain anything! The sprite class doesn't deal with rigidbodies at all...