void Update() { if (true) { EyeTribeClient trackerScript = (EyeTribeClient )FindObjectOfType(typeof(EyeTribeClient)); Vector3 currentPosition = trackerScript.gazePosInvertY; Ray ray = Camera.main.ScreenPointToRay(currentPosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 100)) { Debug.DrawLine(ray.origin, hit.point); if (hit.transform.tag == "ShootingObject") { audio.pitch = Random.Range(0.9f, 1.3f); audio.Play(); GameManager.SP.RemoveObject(hit.transform); } else if (hit.transform.tag == "Can") { audio.PlayOneShot(canHitSound); Vector3 explosionPos = transform.position; hit.rigidbody.AddExplosionForce(5000, explosionPos, 25.0f, 1.0f); } } } }
// Use this for initialization void Start() { _gameControllerRef = this.GetComponent<GameController>(); eyeClient = GameObject.FindGameObjectWithTag("EyeTribeHandler").GetComponent<EyeTribeClient>(); playerRef = _gameControllerRef.players[0].GetComponent<PlayerController>(); }
void OnGUI() { EyeTribeClient trackerScript = (EyeTribeClient )FindObjectOfType(typeof(EyeTribeClient)); Vector3 currentPosition = trackerScript.gazePosNormalY; Rect curpos = new Rect(currentPosition.x, currentPosition.y, currentEyePosition.width, currentEyePosition.height); if (currentPosition.z > 0) { GUI.Label(curpos, currentEyePosition); } }
// Update is called once per frame void Update() { if (playerCamRef == null) playerCamRef = _gameControllerRef.players[0].PlayerCam; if (eyeClient == null) eyeClient = GameObject.FindGameObjectWithTag("EyeTribeHandler").GetComponent<EyeTribeClient>(); if (playerCamRef != null && eyeClient != null && _gameControllerRef.CurrentGameState == GameController.GameState.PLAY) { float currentTime = Time.time; if (currentTime - lastSampling > 1f/MouseTrackFrequencyPerSecond) { lastSampling = currentTime; trackMouse(); trackEyes(); FixationsList.Add(eyeClient.LastFixated); PupilSizeList.Add(eyeClient.LastPupilSize); } if (Input.GetMouseButtonDown(0)) { Vector2 clickPos = Input.mousePosition; clickPos.y = Screen.height - clickPos.y; if (playerRef.bSelectingTactics) TAISLeftClickPoints2D.Add(clickPos); LeftClickPoints2D.Add(clickPos); Ray clickRay = playerCamRef.ScreenPointToRay(clickPos); RaycastHit[] hits = Physics.RaycastAll(clickRay); Vector3 clickPos3D = Vector3.zero; foreach (RaycastHit hit in hits) { if (hit.collider.GetType() == typeof(TerrainCollider)) { clickPos3D = new Vector3(hit.point.x, hit.point.y, hit.point.z); break; } } if (playerRef.bSelectingTactics) TAISLeftClickPoints3D.Add(clickPos3D); LeftClickPoints3D.Add(clickPos3D); } if (Input.GetMouseButtonDown(1)) { Vector2 clickPos = Input.mousePosition; clickPos.y = Screen.height - clickPos.y; if (playerRef.bSelectingTactics) TAISRightClickPoints2D.Add(clickPos); RightClickPoints2D.Add(clickPos); Ray clickRay = playerCamRef.ScreenPointToRay(clickPos); RaycastHit[] hits = Physics.RaycastAll(clickRay); Vector3 clickPos3D = Vector3.zero; foreach (RaycastHit hit in hits) { if (hit.collider.GetType() == typeof(TerrainCollider)) { clickPos3D = new Vector3(hit.point.x, hit.point.y, hit.point.z); break; } } if (playerRef.bSelectingTactics) TAISRightClickPoints3D.Add(clickPos3D); RightClickPoints3D.Add(clickPos3D); } } }