Hello, I would like to instantiate an object when a value is set to True. I have been fighting with this code and cannot seem to get it right. I would appreciate some help. I have two scripts: script1 supposed to set up the value to true if collision happen and script2 create the instantiation. Right now the value passed to script2 is always false therefore no instantiation is happening. Thanks.
static var hasPos1Contact = false;
function Update () {
if(hasPos1Contact==true)
{
hasPos1Contact=true;
}
else
{
hasPos1Contact = false;
}
}
function OnCollisionStay(collision : Collision) {
for (var contact : ContactPoint in collision.contacts) {
hasPos1Contact = true;
}
}
function Update() {
if(other.hasPos1Contact==true)
{
Instantiate (button, Vector3(85.89714, -74.61391, 0),Quaternion.identity);
}