Xcode Error

I am getting an Xcode Error, ONLY while playing my Ipad game when it is plugged into the macbook/Xcode. This error pauses the game indefinitely. If I unplug the Ipad, and then restart the game it does not happen. What is causing this error message within XCode? Right click to view it bigger (obviously).

I might be stating the obvious but have you followed the instructions printed in the output window at the bottom?

You should take a look at your Player.ShieldBash() coroutine (check top of stack trace shown in Xcode). At some point it is producing null reference exception by accessing uninitialized variable.

Its never obvious with me lol thanks for the suggestions. I seemed to have fixed the animation error, but I am still getting an error. Oddly, it still seems to be when I am using the shield bash in the game, but the error is not the same this time. Do you guys see anything? Thanks.

If you look at the left sidebar of the debugger you can see line “0 Pirate_Red_OnTriggerEnter”. This is the clue. Investigate Pirate.Red.OnTriggerEnter() function for crash cause.

I did a few more tests, and it happens with other enemies too. Why would this error only occur when the ipad is plugged into Xcode?

As Mantas said investigate “0 Pirate_Red_OnTriggerEnter” because when you have the iPad plugged into XCode you are essentially giving your game an extra set of controls it was not programmed to contend with.

Ok I am doing a bunch of tests, I’ll post back.

If you are compiling with script debugging enabled and attaching Monodevelop debugger then it is expected. Monodevelop debugger can’t be used at the same time as Xcode debugger, because they interfere with each other. If you are going for debug session with Monodevelop then you should launch app on device manually (not using Xcode).

I need to revive this thread because I am still getting the error. (deleted the post that said it was solved) I have noticed that it seems to be very random and I can’t figure out why it is happening. In the bottom right corner of the picture above, I see that unity is unloading unused assets that are not in the scene, could unity be unloading my assets that I am instantiating? Let’s assume that it is possible, and that the asset has been unloaded, this is how I am instantiating, would it cause a problem?

var peasantBL : Transform = Instantiate (pBlue, transform.position, transform.rotation);

Should I use Resources.Load in the instantiate instead? Something like this:

var pBlue : GameObject = Instantiate(Resources.Load("Peasant_Blue", GameObject));

Would that reload the asset, in case it actually was unloaded? Is there any other way to keep unity from unloading the asset? I know there is DontDestoryOnLoad but the assets aren’t in the scene on load, they are instantiated in waves. Any help would be appreciated, I am completely stumped.