Collisions.

Alright this is proboly really stupid, but I don’t see how this doesn’t work…

function OnCollisionEnter(collision : Collision)
{
transform.position += Vector3.up;
}

This is inside a cube

Make sure your cube and the object it collides with has a collider attached and is in the right object layer (you can define which layers collide with eachother in the project settings) Not sure if a rigidbody is required but I don’t think so.

P.S. Please use the CODE tags next time you post a piece of code on the forum. It makes sure to keep the formatting

Right object layer?

If you select an object in the scene, you will see this in the inspector

1428819--75694--$unity object layer.png

Make sure it is set to the default layer or a layer that collides with the layer the other object is set to.

It’s set to default

Furthermore, the OnCollisionEnter only gets called when an object moves towards the cube and therefor hits it. It is not called when it is instantiated inside the cube or when it is placed inside the cube via the scene view before you start playing, AFAIK

not sure if this is a bug or intended behaviour