|
Post by gregba on Jul 4, 2020 18:07:12 GMT
What would be the best way to call an action such as crouch, roll or jump from script?
Thanks in advance!
|
|
|
Post by mrquaid on Jan 24, 2021 0:37:01 GMT
using Invector.vCharacterController;
public class YourPlayerScriptName : MonoBehaviour { [SerializeField] private vThirdPersonController thirdPersonController; [SerializeField] private Animator animator;
private void Update() { Jump(); } private void Jump() { if (Input.GetKeyDown(KeyCode.Space) && animator.GetBool("IsGrounded")) { thirdPersonController.Jump(); thirdPersonController.ChangeStamina(-25); } } }
|
|
|
Post by mrquaid on Jan 24, 2021 0:39:33 GMT
You can do something like that, funny enough I just wanted to do that today and found this way and saw your question. Prob other ways to do it but that is one way to call those functions. I do it for roll and jump as I want to roll with targeting ememies and jump when not. I had to add the stamina change manually too, and also dont forget to disable the jump in the melee or shooter inputs unless you want like a different button.
|
|