Skip to content

Commit b6bdba4

Browse files
committed
feature (Player): Added run code
1 parent 04d83d0 commit b6bdba4

File tree

4 files changed

+44
-2
lines changed

4 files changed

+44
-2
lines changed

Assets/Resources/Debug.prefab

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ GameObject:
1010
- 4: {fileID: 402906}
1111
- 114: {fileID: 11447320}
1212
- 114: {fileID: 11479902}
13+
- 114: {fileID: 11435634}
1314
m_Layer: 0
1415
m_Name: Debug
1516
m_TagString: Untagged
@@ -29,6 +30,17 @@ Transform:
2930
m_Children: []
3031
m_Father: {fileID: 0}
3132
m_RootOrder: 0
33+
--- !u!114 &11435634
34+
MonoBehaviour:
35+
m_ObjectHideFlags: 1
36+
m_PrefabParentObject: {fileID: 0}
37+
m_PrefabInternal: {fileID: 100100000}
38+
m_GameObject: {fileID: 101550}
39+
m_Enabled: 1
40+
m_EditorHideFlags: 0
41+
m_Script: {fileID: 11500000, guid: 97c5bb23a7720e74f8566205e046d014, type: 3}
42+
m_Name:
43+
m_EditorClassIdentifier:
3244
--- !u!114 &11447320
3345
MonoBehaviour:
3446
m_ObjectHideFlags: 1

Assets/Scripts/Character/CharacterInput.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ public void Parse(int inputState)
3535
currentInput.setYaw(cameraAim.yaw);
3636

3737
currentInput.inputJump = Input.GetButton("Jump");
38+
currentInput.inputFire = Input.GetButton("Fire1");
39+
currentInput.inputAim = Input.GetButton("Fire2");
40+
currentInput.inputRun = Input.GetButton("Run");
3841
}
3942
}
4043

@@ -53,10 +56,14 @@ public struct InputState
5356

5457
public sbyte inputHorizontal;
5558
public sbyte inputVertical;
56-
public bool inputJump;
5759
public short pitch;
5860
public short yaw;
5961

62+
public bool inputJump;
63+
public bool inputFire;
64+
public bool inputAim;
65+
public bool inputRun;
66+
6067
public void setPitch(float value)
6168
{
6269
pitch = (short)(value * 10);

Assets/Scripts/Character/CharacterMovement.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ public class CharacterMovement : MonoBehaviour {
99
[SerializeField]
1010
public float speed = 6.0F;
1111
[SerializeField]
12+
public float runSpeed = 8.0F;
13+
[SerializeField]
1214
public float jumpHeight = 8.0F;
1315
[SerializeField]
1416
public float gravity = 20.0F;
@@ -58,7 +60,12 @@ void SuperUpdate()
5860
}
5961

6062
//Calculate movement from keys
61-
Vector3 movement = Vector3.MoveTowards(moveDirection, LocalMovement() * speed, Mathf.Infinity);
63+
float actualSpeed = speed;
64+
if (input.currentInput.inputRun)
65+
{
66+
actualSpeed = runSpeed;
67+
}
68+
Vector3 movement = Vector3.MoveTowards(moveDirection, LocalMovement() * actualSpeed, Mathf.Infinity);
6269

6370
//Add jump velocity if jumping
6471
if (input.currentInput.inputJump && AcquiringGround())

ProjectSettings/InputManager.asset

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,22 @@ InputManager:
101101
type: 0
102102
axis: 0
103103
joyNum: 11
104+
- serializedVersion: 3
105+
m_Name: Run
106+
descriptiveName:
107+
descriptiveNegativeName:
108+
negativeButton:
109+
positiveButton: right shift
110+
altNegativeButton:
111+
altPositiveButton: left shift
112+
gravity: 1000
113+
dead: .00100000005
114+
sensitivity: 1000
115+
snap: 0
116+
invert: 0
117+
type: 0
118+
axis: 0
119+
joyNum: 11
104120
- serializedVersion: 3
105121
m_Name: Mouse X
106122
descriptiveName:

0 commit comments

Comments
 (0)