So I have a script where as soon as a box is spawned, it flings up into the air, and falls back down. The box hits an object with a tag of ‘Platform’ and then the box freezes, stuck to the platform. They both have Colliders. How come when the box hits the platform, the box just bounces off? This is the script which is causing me that problem:
var FreezeAllow : boolean;
function Start () {
FreezeAllow=false;
yield WaitForSeconds(1);
FreezeAllow=true;
}
function OnCollisionEnter(info : Collision){
if (FreezeAllow==true)
{
if (info.gameObject.tag == “Platform”) {
info.gameObject.rigidbody.useGravity=false;
info.gameObject.rigidbody.drag=info.gameObject.rigidbody.drag+500;
}
}
}
This is the shortened version which works but the boxes stick to everything when they hit (which I don’t want):
var FreezeAllow : boolean;
function Start () {
FreezeAllow=false;
yield WaitForSeconds(1);
FreezeAllow=true;
}
function OnCollisionEnter(info : Collision)
{
if (FreezeAllow==true)
{
info.gameObject.rigidbody.useGravity=false;
info.gameObject.rigidbody.drag=info.gameObject.rigidbody.drag+500;
}
}