summaryrefslogtreecommitdiff
path: root/ActiveRagdoll/Assets/TABG/Scripts/Input/InputHandler.cs
blob: da174de1bde63736931063852216075950af146b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using Rigging.Action;
using Rigging.Cameras;
using Rigging.Data;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;

namespace Rigging.Inputs
{

    public class InputHandler : MonoBehaviour
    {
        public Vector3 inputMovementDirection;

        public Vector3 lastInputDirection;

        public bool allowStrafe = true;

        private MovementDataHandler movementData;

        private Movement movement;

        public bool isSpringting = false;

        private void Start()
        {
            movementData = GetComponentInChildren<MovementDataHandler>();
            movement = GetComponentInChildren<Movement>();
        }

        private void Update()
        {
            inputMovementDirection = Vector3.zero;
            if (Input.GetKey(KeyCode.W))
            {
                inputMovementDirection += movementData.groundedForward;
            }
            if (Input.GetKey(KeyCode.S))
            {
                inputMovementDirection += movementData.groundedBack;
            }
            if (Input.GetKey(KeyCode.D) && allowStrafe)
            {
                inputMovementDirection += movementData.right;
            }
            if (Input.GetKey(KeyCode.A) && allowStrafe)
            {
                inputMovementDirection += movementData.left;
            }
            //if (Input.GetKey(KeyCode.LeftShift) && (!cameraMovement || !cameraMovement.ADS))
            //{
            //    isSpringting = true;
            //}
            if (inputMovementDirection != Vector3.zero)
            {
                lastInputDirection = inputMovementDirection;
            }
            if ((bool)movement && Input.GetKeyDown(KeyCode.Space))
            {
                movement.Jump();
            }
        }

    }

}