Space Shooter Destroy by Contact is dropping FPS! (error: IsFinite(outDistanceAlongView))
I don't know exactly what's going on but my ´´Destroy by Contact`` script that I wrote following the Space Shooter tutorial is acting strange.
When I hit play everything works fine as expected, but whenever I destroy an asteroid I get two error messages and theses messages keep repeating infinitely as the asteroids are destroyed.
One note: the FPS drop increase as the asteroids are destroyed. Here is the script and error message:
(ps. when I remove this line of command, that make the explosion, the error message, also the fps drop stop happening)
One more important note: when an asteroid is destroyed, its explosion effect remain in the scene, as shown in the hierarchy, see:
http://i.imgur.com/hnfT6W3.jpg (couldn't upload more imagens here)
Could somebody please help me with this problem? I'm starting with Unity and don't know what to do.
Error messages:
IsFinite(outDistanceForSort)
IsFinite(outDistanceAlongView)
There is this another error that is shown first than the others, but it appears just a single time:
aabb.IsFinite()
Answer by ykeyani · Dec 30, 2015 at 01:38 PM
The error is related to the rotation, changing rotation to a fixed value like Quaternion.identity will stop the errors.
Instantiate (explosion, transform.position, Quaternion.identity);
In many cases these errors are due to invalid values. You can try testing values before using them which will make your code more stable to changes (defensive programming).
Also It might not actually be a unity bug. I think unity 5 does less error handling.
Answer by A_Li_N · Dec 30, 2015 at 04:53 AM
http://answers.unity3d.com/questions/13544/many-isfinite-errors.html
That looks and sounds much more like a Unity bug than a script bug; might try reporting it.
Answer by HackNslasheR · Jan 05, 2016 at 05:09 PM
@ykeyani and @A_Li_N
Thanks for replying, before trying this solution I posted the same question on a Brazilian group on facebook I participate, and I got a solution. They said it's a bug from a version I was using, "5.3.1f" or something like that.
I tried the version they recommended me, "5.3.1p1", and it works perfectly, with no errors, I needed change nothing.
I think it might be a bug since another version showed that the game can run with no erros using the same code.
Answer by J_Loubert · Jan 12, 2016 at 04:57 PM
@HackNslasheR hi there, I found I was getting the exact same error but it would occur with both the asteroid explosion and player ship explosion. As @ykeyani pointed out, replacing that part of the code with Quaternion.identity in both instances fixed it. running version 5.3.1f1 personal