Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Movement_Player : MonoBehaviour
- {
- [Header("States (?)")]
- public HoC_Input Controls;
- [SerializeField] private bool isSprinting = false;
- [SerializeField] private Vector2 curDir;
- private void Awake()
- {
- Controls = new HoC_Input();
- //Movement
- Controls.Player.Move.performed += ctxCurDir => curDir = ctxCurDir.ReadValue<Vector2>();
- Controls.Player.Move.performed += ctxMove => Move(ctxMove.ReadValue<Vector2>());
- }
- private void OnEnable()
- {
- Controls.Enable();
- }
- private void OnDisable()
- {
- Controls.Disable();
- }
- [Header("Stats")]
- public float Speed = 5;
- public float SprintSpeed = 7.5f;
- private void Move(Vector2 dir)
- {
- gameObject.transform.position += (new Vector3(dir.x, 0, dir.y) * (isSprinting ? SprintSpeed : Speed)) * Time.fixedDeltaTime;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement