There arent any errors that prevent me from playing, and it seems to work, but the ray is really off. I have found that I have to move the camera 90 degrees to the right for it to allow me to pick it up. Any suggestions?
#pragma strict
function Start () {
}
var guiray : GUIText;
var flashlight : GameObject;
var flashlightdesk : GameObject;
function Update () {
var hit : RaycastHit;
var ray = camera.ScreenPointToRay (Vector3(200,200,0));
Debug.DrawRay (ray.origin, ray.direction * 10, Color.yellow);
var fwd = transform.TransformDirection (Vector3.forward);
if (Physics.Raycast(ray, hit, 10)){
// print ("There is something in front of the object!");
// var fingerCount = 0;
// for (var touch : Touch in Input.touches) {
// if (touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled)
// fingerCount++;
// }
// if (fingerCount > 0){
// print ("User has " + fingerCount + " finger(s) touching the screen");
if(hit.collider.gameObject.CompareTag("light")) {
guiray.text = "Pick Up Flashlight";
// if (Input.touchCount > 0) {
if (Input.GetButtonDown("Fire1")){
flashlight.gameObject.active = true;
//flashlight.gameObject.enabled = true;
flashlightdesk.gameObject.active = false;
}
}
else {
guiray.text = "";
}
}
}