private void HandleShot(bool isFreeze) { if (isOnCD || Time.timeScale == 0) { return; } gunAnimator.SetTrigger("shootTrigger"); SoundManager.Instance.PlayNewSound(AudioType.gunShot); //We shoot a Ray through the middle of our screen and see what we find if (Physics.Raycast(Camera.main.ViewportPointToRay(new Vector3(.5f, .5f, 0)), out RaycastHit hit)) { //Debug.Log($"found: {hit.collider.name}"); if (hit.collider.GetComponentInParent <GravityPhysics>() != null) { ActivateLightning(hit.point); GravityPhysics other = hit.collider.GetComponentInParent <GravityPhysics>(); if (isFreeze) { HandleFreezeOnOther(other); } else { HandleFlipOnOther(other); } } } isOnCD = true; }
// Start is called before the first frame update void Start() { gravity = GetComponent <GravityPhysics>(); Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; startPosition = transform.position; startRotation = transform.rotation; }
private void HandleFreezeOnOther(GravityPhysics other) { if (other.IsEnabled()) { other.DisableGravity(); } else { other.EnableGravity(); } }
private void HandleFlipOnOther(GravityPhysics other) { other.FlipGravity(); }