This is my first time using this site, also im am quite a noob lol.
Basically i am using a ray cast in conjunction with a button down to cause a primitive to change direction. i want to randomize the directions of the x and z axis upon button down over the object, but cant figure out how.
Here is what i have so far
var CubePosition : Transform;
public var theCube : GameObject;
function Start () {
}
function Update () {
var hit : RaycastHit ;
var ray:Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast (ray,hit,100)){
Debug.DrawLine(ray.origin,hit.point);
Debug.Log("hit");
if(Input.GetButtonDown("Fire1") && hit.collider.gameObject.name == "theCube"){
/*here is where i want to randomize where my "box primitive is facing, as upon pressing the button, i would like the object to randomly face either the z+ or -, or the x + or -"
}
}
}
i just cant figure out how, and any help would be greatly appreciated, thanks in advance.