Build standalone different then Editor

I have a problem where when I build my game in the standalone version. It behaves differently then when I am working on it in the editor. The issue come at a part in my game where you can shoot hooks that lock onto other objects and allow you to drag them. In the editor it behaves fine, but in the standalone version I shoot the hook and it just bounces off the object.

The code is supposed to create a fixed joint between the two objects. I use a raycast to find the object I clicked on and then take the hook that will be shot at the target and add a fixed joint component, then finally I add the target object to the hooks fixed joint component. When you let go the fixed joint is deleted.

In the log it says that “NullReferenceException: Object reference not set to an instance of an object” but I don’t understand how it can work in the editor but in the build it gives me an error.

Any help is appreciated thanks.

I have had similar problems in my project. I have discovered using Unity Indie license that if you try to Destroy() an object reference that does not exist or is null the webplayer appears to skip over the parent function all together. This is what I have observed without the proper debugging tools to use with webplayer and is not 100% certain.

for example :
This will work in the editor just fine but does not work in the webplayer or sometimes the standalone.

function destroyJoint(){
	var oldJoint : GameObject = GameObject.Find("jointA1");
	
	Destroy( oldJoint );

}

This example will work:

function destroyJoint(){
	var oldJoint : GameObject = GameObject.Find("jointA1");
	
	if( oldJoint != null ){
	
		Destroy( oldJoint );
	}
}

If this isn’t the exact issue it may help you find the issue that is occuring. This is the best I can do, best of luck!