Hello.
We are working with Unity on a small game that takes physical input from the real world, and converts it coordinates and angles inside the game.
However, we have come across a small problem when trying to instantiate objects based on these coordinates and angles. Basically, our code looks like this:
Vector3 o = new Vector3 (xcoord,ycoord,GameObject.Find("Main Camera").camera.nearClipPlane);
Vector3 p = GameObject.Find("Main Camera").camera.ViewportToWorldPoint(o);
GameObject disc;
disc = (GameObject)Instantiate(GameObject.Find("Saucer"), p, Quaternion.identity);
disc.GetComponent("discmotion").SendMessage("setXangle", xAngle);
disc.GetComponent("discmotion").SendMessage("setYangle", yAngle);
disc.GetComponent("discmotion").SendMessage("applyForce");
Destroy(disc, 20);
However, every once in a while, whilst attempting to instantiate a new disc, Unity comes up with the following error:
PhysicsSDK: createActor: WriteLock is still acquired. Procedure call skipped to avoid a deadlock!
UnityEngine.Object:Instantiate(Object, Vector3, Quaternion)
Subsequently, I also get an error telling me that
m_Actor == NULL
and lastly a null reference error, possibly when I try to set these values subsequently. The first error message refers specifically to the instantiate line.
This does not only not spawn a new disc, but also crashes unity. Any suggestions as how to fix it?
(oh, and please don’t mock my naming conventions! This is still WIP