check on sprinting

This commit is contained in:
mushgunAX 2023-03-09 16:04:25 +08:00
parent 35b60a24e4
commit 8755f1753d
6 changed files with 84 additions and 21 deletions

View File

@ -1,4 +1,4 @@
7 10
Controller Look Horizontal Controller Look Horizontal
0 0
0 0
@ -23,6 +23,32 @@ Controller Look Vertical
1 1
19 19
0 0
Drop
0
0
1000
0.2
1000
0
1
2
0
1
13
0
GrabThrow
0
0
1000
0.2
1000
0
1
1
0
1
11
0
Horizontal Horizontal
0 0
0 0
@ -76,6 +102,19 @@ Mouse Look Vertical
0 0
0 0
0 0
Sprint
0
0
1000
0.2
1000
0
1
160
0
1
6
0
Vertical Vertical
0 0
0 0

View File

@ -297,6 +297,7 @@
Color: {x: 1, y: 1, z: 1, w: 1} Color: {x: 1, y: 1, z: 1, w: 1}
Layer: 4294967295 Layer: 4294967295
Strength: 0 Strength: 0
Casting Shadows: false
IsActive: true IsActive: true
Scripts: ~ Scripts: ~
- EID: 3 - EID: 3

View File

@ -79,7 +79,7 @@ public class PickAndThrow : Script
itemRidigBody.LinearVelocity = Vector3.Zero; itemRidigBody.LinearVelocity = Vector3.Zero;
itemRidigBody.AngularVelocity = Vector3.Zero; itemRidigBody.AngularVelocity = Vector3.Zero;
if (Input.GetMouseButtonDown(Input.MouseCode.LeftButton)) if (Input.GetMouseButtonDown(Input.MouseCode.LeftButton) || Input.GetBindingPositiveButtonDown("GrabThrow"))
{ {
pc.isAiming = true; pc.isAiming = true;
pc.camArm.ArmLength = aimingLength; pc.camArm.ArmLength = aimingLength;
@ -88,7 +88,7 @@ public class PickAndThrow : Script
pc.cam.FOV = aimingFOV; pc.cam.FOV = aimingFOV;
} }
if (Input.GetMouseButtonUp(Input.MouseCode.LeftButton) && pc.isAiming) if ((Input.GetMouseButtonUp(Input.MouseCode.LeftButton) || Input.GetBindingPositiveButtonUp("GrabThrow")) && pc.isAiming)
{ {
AudioHandler.audioClipHandlers["SFXThrow"].Play(); AudioHandler.audioClipHandlers["SFXThrow"].Play();
itemRidigBody.IsGravityEnabled = true; itemRidigBody.IsGravityEnabled = true;
@ -104,7 +104,7 @@ public class PickAndThrow : Script
timer = 0.0f; timer = 0.0f;
} }
if (Input.GetMouseButtonDown(Input.MouseCode.RightButton) && !pc.isAiming) if ((Input.GetMouseButtonDown(Input.MouseCode.RightButton) || Input.GetBindingPositiveButtonDown("Drop")) && !pc.isAiming)
{ {
pc.holdItem = false; pc.holdItem = false;
inRange = false; inRange = false;
@ -113,7 +113,7 @@ public class PickAndThrow : Script
ResetItemObject(); ResetItemObject();
} }
if (Input.GetMouseButtonDown(Input.MouseCode.RightButton) && pc.isAiming) if ((Input.GetMouseButtonDown(Input.MouseCode.RightButton) || Input.GetBindingPositiveButtonDown("Drop")) && pc.isAiming)
{ {
pc.isAiming = false; pc.isAiming = false;
pc.cam.FOV = defaultFOV; pc.cam.FOV = defaultFOV;
@ -130,7 +130,7 @@ public class PickAndThrow : Script
} }
} }
if (timer > delayTimer && pc && !pc.holdItem && inRange && Input.GetMouseButtonDown(Input.MouseCode.LeftButton)) if (timer > delayTimer && pc && !pc.holdItem && inRange && (Input.GetMouseButtonDown(Input.MouseCode.LeftButton) || Input.GetBindingPositiveButtonDown("GrabThrow")))
{ {
if (pc.currentState == RaccoonStates.WALKING || pc.currentState == RaccoonStates.IDLE) if (pc.currentState == RaccoonStates.WALKING || pc.currentState == RaccoonStates.IDLE)
{ {

View File

@ -202,42 +202,54 @@ public class PlayerController : Script
private void MoveKey() private void MoveKey()
{ {
axisMove = Vector2.Zero; axisMove = Vector2.Zero;
if (Input.GetKey(Input.KeyCode.W)) if (Input.GetKey(Input.KeyCode.W) || Input.GetBindingAxisRaw("Vertical") > 0.0f)
{ {
Vector3 camerAixs = cam.GetForward(); Vector3 camerAixs = cam.GetForward();
camerAixs.y = 0; camerAixs.y = 0;
camerAixs.Normalise(); camerAixs.Normalise();
axisMove += new Vector2(camerAixs.x, camerAixs.z); Vector2 forwardMove = new Vector2(camerAixs.x, camerAixs.z);
forwardMove *= Input.GetBindingAxis("Vertical");
//axisMove += new Vector2(camerAixs.x, camerAixs.z);
axisMove += forwardMove;
} }
if (Input.GetKey(Input.KeyCode.S)) if (Input.GetKey(Input.KeyCode.S) || Input.GetBindingAxisRaw("Vertical") < 0.0f)
{ {
Vector3 camerAixs = cam.GetForward(); Vector3 camerAixs = cam.GetForward();
camerAixs.y = 0; camerAixs.y = 0;
camerAixs.Normalise(); camerAixs.Normalise();
axisMove -= new Vector2(camerAixs.x, camerAixs.z); Vector2 forwardMove = new Vector2(camerAixs.x, camerAixs.z);
forwardMove *= Input.GetBindingAxis("Vertical");
//axisMove -= new Vector2(camerAixs.x, camerAixs.z);
axisMove += forwardMove;
} }
if (Input.GetKey(Input.KeyCode.A)) if (Input.GetKey(Input.KeyCode.A) || Input.GetBindingAxisRaw("Horizontal") < 0.0f)
{ {
Vector3 camerAixs = cam.GetRight(); Vector3 camerAixs = cam.GetRight();
camerAixs.y = 0; camerAixs.y = 0;
camerAixs.Normalise(); camerAixs.Normalise();
axisMove -= new Vector2(camerAixs.x, camerAixs.z); Vector2 sideMove = new Vector2(camerAixs.x, camerAixs.z);
sideMove *= Input.GetBindingAxis("Horizontal");
//axisMove -= new Vector2(camerAixs.x, camerAixs.z);
axisMove += sideMove;
} }
if (Input.GetKey(Input.KeyCode.D)) if (Input.GetKey(Input.KeyCode.D) || Input.GetBindingAxisRaw("Horizontal") > 0.0f)
{ {
Vector3 camerAixs = cam.GetRight(); Vector3 camerAixs = cam.GetRight();
camerAixs.y = 0; camerAixs.y = 0;
camerAixs.Normalise(); camerAixs.Normalise();
axisMove += new Vector2(camerAixs.x, camerAixs.z); Vector2 sideMove = new Vector2(camerAixs.x, camerAixs.z);
sideMove *= Input.GetBindingAxis("Horizontal");
//axisMove += new Vector2(camerAixs.x, camerAixs.z);
axisMove += sideMove;
} }
axisMove.Normalise(); //axisMove.Normalise();
isMoveKeyPress = axisMove.x != 0 || axisMove.y != 0; isMoveKeyPress = axisMove.x != 0 || axisMove.y != 0;
if (isMoveKeyPress && isGrounded && !Input.GetKey(Input.KeyCode.LeftShift)) if (isMoveKeyPress && isGrounded && !Input.GetKey(Input.KeyCode.LeftShift) && Input.GetBindingAxisRaw("Sprint") == 0.0f)
{ {
currentState = RaccoonStates.WALKING; currentState = RaccoonStates.WALKING;
@ -276,7 +288,7 @@ public class PlayerController : Script
private void Sprint() private void Sprint()
{ {
if (Input.GetKey(Input.KeyCode.LeftShift) && isMoveKeyPress && isGrounded) if (Input.GetKey(Input.KeyCode.LeftShift) && isMoveKeyPress && isGrounded && Input.GetBindingAxisRaw("Sprint") > 0.0f)
{ {
currentState = RaccoonStates.RUNNING; currentState = RaccoonStates.RUNNING;
if (stateMachine && !stateMachine.IsState(typeof(PlayerRunState))) if (stateMachine && !stateMachine.IsState(typeof(PlayerRunState)))
@ -294,7 +306,7 @@ public class PlayerController : Script
} }
} }
if (Input.GetKeyUp(Input.KeyCode.LeftShift)) if (Input.GetKeyUp(Input.KeyCode.LeftShift) || Input.GetBindingPositiveButtonUp("Sprint"))
{ {
if (isMoveKeyPress) if (isMoveKeyPress)
{ {
@ -312,7 +324,7 @@ public class PlayerController : Script
{ {
if (currentState == RaccoonStates.WALKING || currentState == RaccoonStates.RUNNING || currentState == RaccoonStates.IDLE) if (currentState == RaccoonStates.WALKING || currentState == RaccoonStates.RUNNING || currentState == RaccoonStates.IDLE)
{ {
if ( (Input.GetKeyDown(Input.KeyCode.Space) || landedOnJumpPad ) && isGrounded && rb != null) if ( (Input.GetKeyDown(Input.KeyCode.Space) || landedOnJumpPad || Input.GetBindingPositiveButtonDown("Jump")) && isGrounded && rb != null)
{ {
currentState = RaccoonStates.JUMP; currentState = RaccoonStates.JUMP;
Vector3 v = rb.LinearVelocity; Vector3 v = rb.LinearVelocity;
@ -337,7 +349,7 @@ public class PlayerController : Script
} }
} }
if(!isGrounded && rb != null && (rb.LinearVelocity.y < 0.0f || Input.GetKeyUp(Input.KeyCode.Space))) if(!isGrounded && rb != null && (rb.LinearVelocity.y < 0.0f || Input.GetKeyUp(Input.KeyCode.Space) || Input.GetBindingPositiveButtonUp("Jump")))
currentState = RaccoonStates.FALLING; currentState = RaccoonStates.FALLING;
} }

View File

@ -49,7 +49,15 @@ namespace SHADE_Scripting
CameraArm arm = GetComponent<CameraArm>(); CameraArm arm = GetComponent<CameraArm>();
if (arm) if (arm)
{ {
Vector2 vel = Input.GetMouseVelocity(); Vector2 vel = new Vector2();
if (!Input.ControllerInUse)
vel = Input.GetMouseVelocity();
else
{
//TODO REPLACE HARDCODED MULTIPLIER
vel.x = (float)Input.GetBindingAxis("Controller Look Horizontal") * 300.0f;
vel.y = (float)Input.GetBindingAxis("Controller Look Vertical") * 300.0f;
}
if(inverseYControls) if(inverseYControls)
arm.Pitch -= vel.y * turnSpeedPitch * Time.DeltaTimeF; arm.Pitch -= vel.y * turnSpeedPitch * Time.DeltaTimeF;
else else

View File

@ -12,6 +12,9 @@ public class MainMenu : Script
protected override void awake() protected override void awake()
{ {
//Load the bindings
Input.LoadBindings();
AudioHandler.audioClipHandlers["BGMMainMenu"] = Audio.CreateAudioClip("event:/Music/main_menu"); AudioHandler.audioClipHandlers["BGMMainMenu"] = Audio.CreateAudioClip("event:/Music/main_menu");
AudioHandler.audioClipHandlers["SFXMouseDownElement"] = Audio.CreateAudioClip("event:/UI/mouse_down_element"); AudioHandler.audioClipHandlers["SFXMouseDownElement"] = Audio.CreateAudioClip("event:/UI/mouse_down_element");
AudioHandler.audioClipHandlers["SFXUISuccess"] = Audio.CreateAudioClip("event:/UI/success"); AudioHandler.audioClipHandlers["SFXUISuccess"] = Audio.CreateAudioClip("event:/UI/success");