Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Extras;
- using UnityEngine;
- namespace Core
- {
- [RequireComponent(typeof(CharacterMovement))]
- public class CharacterRun : CharacterComponent
- {
- private static readonly int RunningParam = Animator.StringToHash("Running");
- private CharacterMovement _characterMovement;
- [SerializeField] private float runSpeed = 5;
- public override void Awake()
- {
- base.Awake();
- _characterMovement = GetComponent<CharacterMovement>();
- }
- private void Update()
- {
- if (Character.characterType != CharacterType.Player)
- return;
- if (Input.GetKeyDown(KeyCode.LeftShift))
- Run();
- else
- StopRun();
- }
- private void Run()
- {
- _characterMovement.speedMultiplier *= runSpeed;
- }
- private void StopRun()
- {
- _characterMovement.speedMultiplier = 1.0f;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement