Files changed (1) hide show
  1. Assets/ThirdPersonUserControlHFT.cs +17 -5
Assets/ThirdPersonUserControlHFT.cs CHANGED
@@ -5,7 +5,7 @@ using UnityStandardAssets.CrossPlatformInput;
5
5
namespace UnityStandardAssets.Characters.ThirdPerson
6
6
{
7
7
[RequireComponent(typeof (ThirdPersonCharacter))]
8
- public class ThirdPersonUserControl : MonoBehaviour
8
+ public class ThirdPersonUserControlHFT : MonoBehaviour
9
9
{
10
10
private ThirdPersonCharacter m_Character; // A reference to the ThirdPersonCharacter on the object
11
11
private Transform m_Cam; // A reference to the main camera in the scenes transform
@@ -13,6 +13,8 @@ namespace UnityStandardAssets.Characters.ThirdPerson
13
13
private Vector3 m_Move;
14
14
private bool m_Jump; // the world-relative desired move direction, calculated from the camForward and user input.
15
15
16
+ private HFTInput m_hftInput;
17
+ private HFTGamepad m_gamepad;
16
18
17
19
private void Start()
18
20
{
@@ -30,14 +32,24 @@ namespace UnityStandardAssets.Characters.ThirdPerson
30
32
31
33
// get the third person character ( this should never be null due to require component )
32
34
m_Character = GetComponent<ThirdPersonCharacter>();
35
+
36
+ m_hftInput = GetComponent<HFTInput>();
37
+ m_gamepad = GetComponent<HFTGamepad>();
38
+
39
+ m_gamepad.OnDisconnect += Remove;
33
40
}
34
41
42
+ void Remove()
43
+ {
44
+ Destroy(gameObject);
45
+ }
35
46
36
47
private void Update()
37
48
{
38
49
if (!m_Jump)
39
50
{
40
- m_Jump = CrossPlatformInputManager.GetButtonDown("Jump");
51
+ m_Jump = CrossPlatformInputManager.GetButtonDown("Jump") ||
52
+ m_hftInput.GetButtonDown("fire1");
41
53
}
42
54
}
43
55
@@ -46,9 +58,9 @@ namespace UnityStandardAssets.Characters.ThirdPerson
46
58
private void FixedUpdate()
47
59
{
48
60
// read inputs
49
- float h = CrossPlatformInputManager.GetAxis("Horizontal");
50
- float v = CrossPlatformInputManager.GetAxis("Vertical");
51
- bool crouch = Input.GetKey(KeyCode.C);
61
+ float h = CrossPlatformInputManager.GetAxis("Horizontal") + m_hftInput.GetAxis("Horizontal");
62
+ float v = CrossPlatformInputManager.GetAxis("Vertical") - m_hftInput.GetAxis("Vertical");
63
+ bool crouch = Input.GetKey(KeyCode.C) || m_hftInput.GetButton("fire2");
52
64
53
65
// calculate move direction to pass to character
54
66
if (m_Cam != null)