forked from JLPM22/MotionMatching
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputCharacterController.cs
More file actions
67 lines (60 loc) · 1.75 KB
/
Copy pathInputCharacterController.cs
File metadata and controls
67 lines (60 loc) · 1.75 KB
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MotionMatching;
[RequireComponent(typeof(InputManager))]
/// <summary>
/// This class listents to InputManager and input the desired information to SpringCharacterController.
/// </summary>
public class InputCharacterController : MonoBehaviour
{
private InputManager Input;
private IPlayerInputCharacterController CharacterController;
private TagSwitchHelper TagHelper;
private void Awake()
{
Input = GetComponent<InputManager>();
CharacterController = GetComponent<IPlayerInputCharacterController>();
TagHelper = GetComponent<TagSwitchHelper>();
}
private void OnEnable()
{
Input.OnMovementDirectionChanged += OnMovementDirectionChanged;
Input.OnFixOrientationSwap += OnFixOrientationSwap;
Input.OnSwitchTag += OnSwitchTag;
}
private void OnDisable()
{
Input.OnMovementDirectionChanged -= OnMovementDirectionChanged;
Input.OnFixOrientationSwap -= OnFixOrientationSwap;
Input.OnSwitchTag -= OnSwitchTag;
}
public void OnMovementDirectionChanged(Vector2 movementDirection)
{
if (CharacterController != null)
{
CharacterController.SetMovementDirection(movementDirection);
}
}
public void OnFixOrientationSwap()
{
if (CharacterController != null)
{
CharacterController.SwapFixOrientation();
}
}
public void OnSwitchTag()
{
if (TagHelper != null)
{
if (TagHelper.IsQuerySet)
{
TagHelper.DisableQuery();
}
else
{
TagHelper.UpdateQuery();
}
}
}
}