Hello,
This is my Javascript I made, I need to access the collider on these GameObjects to see if the mouse CLICKS on the Mesh of the Object that i have a MESH COLLIDER on.
Code:
var ButtonLeft:Collider;
var ButtonRight:Collider;
var GridCount : float = 0;
function Update () {
GridCount = Mathf.Clamp (GridCount, 0, 3);
}
function OnMouseDownAsButton () {
if (ButtonRight) {
GridCount ++;
}
if (ButtonLeft) {
GridCount --;
}
if (GridCount == 0) {
if (ButtonRight) {
//Move all level objs left one grid
Debug.Log (GridCount);
}
if (ButtonLeft) {
//Move all level objs right one grid
Debug.Log (GridCount);
}
}
if (GridCount == 1) {
if (ButtonRight) {
//Move all level objs left one grid
Debug.Log (GridCount);
}
if (ButtonLeft) {
//Move all level objs right one grid
Debug.Log (GridCount);
}
}
if (GridCount == 2) {
if (ButtonRight) {
//Move all level objs left one grid
Debug.Log (GridCount);
}
if (ButtonLeft) {
//Move all level objs right one grid
Debug.Log (GridCount);
}
}
}
Hierarchy:
[12895-screen+shot+2013-07-07+at+8.08.59+pm.png|12895]
In the Above Picture the parent object Arrows has the above script on it.
In the above picture each Child Object has a MESH COLLIDER on it.
Now knowing that where the script is how do I access the colliders IN the IF STATEMENTS, I have
Example:
if (ButtonRight) {
GridCount ++;
}
Thanks for the help!
I know its a simple thing, I just cant figure it out!
Daniel