var TheCollision : Collision

function OnCollisionEnter(TheCollision : Collision){
if( == “Floor”){
Debug.Log(“Hit The Floor”);
else if( == “wall”){
Debug.Log(“Hit The Wall”);

This is a simple Collision Javascript.
There is one thing i don’t get since switching Game languages.

In my previous Language it would be.

var x , y; x = mouse_xx y = mouse_yy

That would store xx and yy variable in the current position of the object.

What i do get is this
var Speed : int;
i’ts almost the same, but you can save it as a float or boolean to.

But i don’t get is this

function OnCollisionEnter(TheCollision : Collision)

How does TheCollision variable(if it is) play a part in the Collision ?
That all i don’t get about UnityScript!


The OnCollisionEnter is a method that is called when there is a collision. The information from the collision is stored in the variable TheCollision which you can use to tell what it hit.

UnityScript is the same as JavaScript except that it has it’s own predefined classes and methods that make making a game easier.