balancing board

Quite new to Unity and making a first person platform game. I have built a basic FBX model on google sketch up for my first level. I am looking to make boards that will fall from under the characters feet. I have a tower with a wooden board hanging over the edge, i want to make the board fall if the character goes to far across it, i suspect it has something to do with the OnControllerColliderHit function but not sure how to use this to make the boards fall. The boards are of course not part of my main FBX, they are just cubes made in unity with material added. Thanks in advance.

There are many ways to achieve such a thing, and it really depends on the details.

But, since you want them to fall you are probably wanting to use physics. Creating a cube in Unity, as you did, means the cube has a box collider. So you are half way there.

Select the cube and from the menu Component >> Physics select RigidBody. The cube will now have a rigid body so that it can be simulated in the scene. Make sure the cube is not marked as static.

Press Play and the cube should start falling. It will probably fall straight through your game level that you imported. To fix that select the model for it in the Project to bring up the Inspector settings. Select Generate Colliders and Apply. Make sure you set the game level in the scene to be static. It should now have a mesh collider on it.

Press play and the cube should fall and react to the game level in a physical way. If this works you have half the issue solved.

So now what you want is for it to only do that when the situation is right, that is when the player character is in the right spot I take it.

First, we make it so the cube doesn’t fall before we want it too. Select the cube and check the “Is Kinematic” checkbox on its RigidBody component. This means Physics will not animate the box (which is what we want… for now).

Now create an Empty Game Object and then attach a box collider component to it. Rename it something like “Trigger” to make it easy to find in the Hiearchy. In the settings for its Box Collider, check the “Is Trigger” checkbox. In the scene view the empty game object appears as a green wireframe box… that’s the collider. Position it in your game level in the spot such that if a character walks into it that’s when you want the cube board(s) to fall. Note that if you hold down shift while in transform mode, small green handles will appear on the collider wireframe which lets you adjust its size with the mouse.

Your character will need a collider on it and a rigidbody. Since the character is probably not moving with physics you’d want to set its RigidBody component’s Is Kinematic to true (checked). That way you can move it around without physics trying to animate it.

This is trigger. So create a new script… in my example I call it TriggerMe.cs:

using UnityEngine;
using System.Collections;

public class TriggerMe : MonoBehaviour {

	public Rigidbody Target;

	public void OnTriggerEnter(Collider c)
		Target.isKinematic = false;  // Make target cube fall
		Target.WakeUp();						 // Because it was at rest, it needs a nudge
		enabled = false;             // Disable myself since I'm no longer needed


This makes a new TriggerMe component. Add this to the Trigger object you created earlier.

You will notice that, in the Inspector for the Trigger object, there is now a setting on the Trigger Me component called “Target”. It is set to None. This lets us configure what object we want to start falling. So drag the cube you want to start falling when that trigger is entered from the Hiearchy into the target (or click the little circle to the right of the property and select it form that dialog).

If you press play now you will see that the cube does not fall right away. But if any object that has both a rigidbody and a collider enters the volume of your trigger the box will suddenly give way and fall.

Of course your character, unless it is simulated with physics, will not fall with it. That’s another problem since you are probably currently controlling it by other means. But this should get you moving in the correct direction.

Thanks for your answer, this is not quite what i was looking for but i will use this method anyway. Basically i have a board balancing over an edge of a building and if weight was put on the part that is hanging over the edge it should tip the board up and make it fall. The board is not kinematic at the moment but is not moving because it is balanced on the edge. is there a way to apply weight to the character controller? Or even something along the same lines as your method where a trigger activate causing the board to rotate and then eventually topple itself?