// Update is called once per frame void Update() { if (m_Timer > 0) { m_Timer -= Time.deltaTime; } if (m_Timer <= 0 && InputAbstraction.FireControlActive(InputAbstraction.PreferedHand())) { if (m_NumSpecialAmmo > 0 && specialBulletPrefab != null) { Instantiate(specialBulletPrefab, m_Transform.position, m_Transform.rotation); if (m_audioSource != null) { m_audioSource.PlayOneShot(specialAmmoFireClip); } HapticAbstraction.BuzzBothHands(hapticTime); m_NumSpecialAmmo--; } else if (bulletPrefab != null) { Instantiate(bulletPrefab, m_Transform.position, m_Transform.rotation); if (m_audioSource != null) { m_audioSource.Play(); } HapticAbstraction.BuzzBothHands(hapticTime); } m_Timer = cooldown; } }
float GetDegreeRotation() { float degrees = 0f; float X = InputAbstraction.GetAxis(InputAbstraction.AxisAlias.X, InputAbstraction.PreferedHand()); float Y = InputAbstraction.GetAxis(InputAbstraction.AxisAlias.Y, InputAbstraction.PreferedHand()); bool XIsNegative = X < 0 ? true : false; bool YIsNegative = Y < 0 ? true : false; X = Mathf.Abs(X); Y = Mathf.Abs(Y); degrees = (YIsNegative ^ XIsNegative) ? Mathf.Atan(Y / X) * (180 / Mathf.PI) : Mathf.Atan(X / Y) * (180 / Mathf.PI); if (YIsNegative && !XIsNegative) { degrees += 90; } else if (YIsNegative && XIsNegative) { degrees += 180; } else if (!YIsNegative && XIsNegative) { degrees += 270; } return(degrees); }
// Update is called once per frame void Update() { // Do Raycast RaycastHit hit = new RaycastHit(); if (Physics.Raycast(transform.position, transform.forward, out hit, Mathf.Infinity, layerMask)) { // Show navigation aid m_NavigationAidPrefab.SetActive(true); m_NavigationAidPrefab.transform.position = hit.point; // Handle input if (InputAbstraction.GetButtonDown(InputAbstraction.ButtonAlias.AXIS_CLICK, InputAbstraction.PreferedHand())) { if (m_nmAgent == null) { m_nmAgent = GameManager.instance.player.GetComponent <NavMeshAgent>(); } if (m_nmAgent != null) { m_nmAgent.destination = hit.point; if (m_audioSource != null) { m_audioSource.Play(); } } } } else { m_NavigationAidPrefab.SetActive(false); } }