Hi,
I’m starting a new thread, because I didn’t have any luck on my last one. Below, is my script for destroying a script after 2 objects enter a trigger. I haven’t had any luck so far…
function OnTriggerEnter(other : Collider)
{
// Destroy the script
Destroy(other.gameObject.GetComponent(MovementControl));
if (other.attachedRigidbody) {
//setting rigidbody gravity boolean to true
other.attachedRigidbody.useGravity = true;
}
}
So, this is what I want to have happen:
-“Cube A” has a rigidbody and a script called “MovementControl” attached so the player can move it.
-“Cube B” has the “is Trigger” enabled and the script above attached to it.
“Cube A” is supposed to collide with “Cube B” and after doing so, the “MovementControl” script attached to “Cube A” should be destroyed and it should come to a stop on top of “Cube B”. Instead of stopping, “Cube A” passes directly through “Cube B” and losses the “MovementControl” script when it collides with other objects that don’t have the “is Trigger” enabled. When I disable the “is Trigger” on “Cube B”, the “MovementControl” script is destroyed when the 2 cubes come in contact, which is strange to me, but I’m brand new to this stuff. Can someone please help?
Thanks in advance for your help.