TriggerEnter, useGravity, Cubes are not falling down

Hello, i have problem.

I got two cubes. Cube > with a collider and rigidbody, useGravity is unchecked. Cube > with a collider and script attached on it. Script:

var ObjectToFall : UnityEngine.GameObject;

function OnTriggerEnter ( other : Collider ) {
ObjectToFall.rigidbody.useGravity = true;

So when i collide it with my playercontroller (2d platform tutorial), first cube will fall down, checking on the useGravity. It not works, why? (If i push the first cube, it slowy moves in direction where i have pushed it)

Your description gets very confusing towards the end when you suddenly start talking about a character controller and pushing. What do you mean by this?

There are several reasons why OnTriggerEnter may not work:

  1. Your GameObject with the trigger script does not have a Rollider.
  2. Your GameObject with the trigger script's Collider does not have the isTrigger checked.
  3. Your GameObject with the trigger script's trigger script instance's ObjectToFall instance is not set.
  4. Your GameObject with the Rigidbody does not have a Rollider.
  5. Your GameObject with the Rigidbody's Rigidbody is asleep.

to name a few.

Since 1-4 are pretty rudimentary, your most likely culprit above is 5. Unless your rigidbody is moving, changing, etc. it will be asleep and will not set off OnTriggerEnter. See this doc for more. The simple solution is to force it to wake up within some proximity to your trigger, but this does not scale well as for n rigidbodies this becomes much more costly and complicated to handle. For those cases, you may want to use a different mechanism than depending upon OnTriggerEnter.

To force awake, you could add something in your trigger script like:

var range : float = 3.0f;

function Update() {
    if(ObjectToFall &&
       (ObjectToFall.transform.position - transform.position).magnitude <= range)

It sounds like you want the player to enter an area represented by cube A, causing cube B to fall. Is that right?

You are putting code in OnTriggerEnter. Make sure Is Trigger on cube A is true (checkbox is checked.)

Make sure ObjectToFall on cube A was assigned the cube that you want to fall (cube B).

If neither of these help, it might help to narrow down the problem. While the game is running, select cube B in the Inspector. You should be able to see the Use Gravity checkbox switch on when the player hits cube A. You can also try toggling Use Gravity on manually. This will help you narrow down whether the problem is with the cube A trigger, or the gravity on cube B.

Thanks for fast replys, iam really an idiot! isTrigger was unchecked... Now my next question, how to make isTrigger checked and make the cube like it is unchecked. So, the isTrigger = true & my character dont go trough it