// Update is called once per frame void Update() { if (cC.currentState == characterController.playerState.TAMING) { if (cC.enteredTaming == false) { tamingSlider.value = charInt.hB.tamingGoal / 4; cC.enteredTaming = true; } tamingSliderParent.SetActive(true); tamingSlider.maxValue = charInt.hB.tamingGoal; tamingSlider.value = tamingSlider.value - charInt.hB.timerDecrease * Time.deltaTime; if (Input.GetKeyDown(tameKey)) { tamingSlider.value = tamingSlider.value + 10; } if (tamingSlider.value == tamingSlider.maxValue) { charInt.hB.isTamed = true; cC.goToRide(); } } else { tamingSliderParent.SetActive(false); } }
// Update is called once per frame void Update() { if (cC.currentState == characterController.playerState.GROUNDED || cC.currentState == characterController.playerState.JUMPING) { if (Physics.Raycast(cC.cam.transform.position, cC.cam.transform.forward, out var rayHit, interactDistance, interactableLayers)) { if (rayHit.collider.gameObject.tag == "horse") { hB = rayHit.collider.gameObject.GetComponent <horseBehaviour>(); targetName.text = hB.horseName; if (Input.GetKeyDown(interactKey)) { transform.position = hB.myRideAnchor.position; transform.SetParent(hB.myRideAnchor); transform.rotation = new Quaternion(0, 0, 0, 0); cC.rb.constraints = RigidbodyConstraints.FreezeAll; cC.myCap.enabled = false; if (hB.isTamed) { cC.goToRide(); } else { cC.goToTame(); } } } if (rayHit.collider.gameObject.tag == "throwable") { var tS = rayHit.collider.gameObject.GetComponent <throwablesScript>(); targetName.text = tS.myName; if (Input.GetKeyDown(interactKey)) { heldThrowables.Add(rayHit.collider.gameObject); rayHit.collider.gameObject.SetActive(false); } } } else { targetName.text = ""; } }