private void PlayerInteraction() { IInteract iIteract = null; BreakWindow _car; if (Input.GetButtonDown("GetDog")) { if (_shibaHolder.GetComponentInChildren <Rigidbody>() != null) { Rigidbody rb = _shibaHolder.GetComponentInChildren <Rigidbody>(); Transform transformShiba = _shibaHolder.GetComponentInChildren <Rigidbody>().transform; rb.useGravity = true; rb.isKinematic = false; rb.AddForce(0, _throwForce / 2, _throwForce / 4, ForceMode.Force); transformShiba.SetParent(null); } if (_shibaHolder.GetComponentInChildren <Rigidbody>() == null) { if (Physics.Raycast(transform.GetChild(1).position, transform.GetChild(1).forward, out _hit, 150)) { if (_hit.transform.GetComponent <Shiba>() != null) { _hit.transform.GetComponent <Shiba>().transform.SetParent(ShibaHolder.transform); _hit.transform.GetComponent <Shiba>().transform.position = ShibaHolder.transform.position; _hit.transform.GetComponent <Rigidbody>().useGravity = true; _hit.transform.GetComponent <Rigidbody>().isKinematic = false; } } if (Physics.Raycast(transform.GetChild(1).position, transform.GetChild(1).forward, out _hit, 150)) { if (_hit.transform.GetComponent <IInteract>() != null) { _car = _hit.transform.GetComponent <BreakWindow>(); if (iIteract == null) { iIteract = _hit.transform.GetComponent <IInteract>(); } if (_car.HitWindow >= 0) { iIteract.OnInteract(); } } } } } }