Compare commits
4 Commits
main
...
Controller
Author | SHA1 | Date |
---|---|---|
mushgunAX | 327d96ccd8 | |
mushgunAX | 0b967154ba | |
mushgunAX | d95d0be5e3 | |
mushgunAX | 8755f1753d |
|
@ -1,4 +1,4 @@
|
|||
7
|
||||
10
|
||||
Controller Look Horizontal
|
||||
0
|
||||
0
|
||||
|
@ -23,6 +23,32 @@ Controller Look Vertical
|
|||
1
|
||||
19
|
||||
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
|
||||
0
|
||||
0
|
||||
|
@ -76,6 +102,19 @@ Mouse Look Vertical
|
|||
0
|
||||
0
|
||||
0
|
||||
Sprint
|
||||
0
|
||||
0
|
||||
1000
|
||||
0.2
|
||||
1000
|
||||
0
|
||||
1
|
||||
160
|
||||
0
|
||||
1
|
||||
6
|
||||
0
|
||||
Vertical
|
||||
0
|
||||
0
|
||||
|
|
|
@ -3184,6 +3184,7 @@
|
|||
inverseYControls: false
|
||||
pitchUpperClamp: 45
|
||||
pitchLowerClamp: 5
|
||||
cameraSensitivity: 400
|
||||
- EID: 9
|
||||
Name: PlayerBag
|
||||
IsActive: true
|
||||
|
|
|
@ -74,7 +74,7 @@ public class PickAndThrow : Script
|
|||
itemRidigBody.LinearVelocity = 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.camArm.ArmLength = aimingLength;
|
||||
|
@ -83,7 +83,7 @@ public class PickAndThrow : Script
|
|||
pc.cam.FOV = Settings.cameraFOV + 5;
|
||||
}
|
||||
|
||||
if (Input.GetMouseButtonUp(Input.MouseCode.LeftButton) && pc.isAiming)
|
||||
if ((Input.GetMouseButtonUp(Input.MouseCode.LeftButton) || Input.GetBindingPositiveButtonUp("GrabThrow")) && pc.isAiming)
|
||||
{
|
||||
AudioHandler.audioClipHandlers["SFXThrow"].Play();
|
||||
itemRidigBody.IsGravityEnabled = true;
|
||||
|
@ -99,7 +99,7 @@ public class PickAndThrow : Script
|
|||
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;
|
||||
inRange = false;
|
||||
|
@ -108,7 +108,7 @@ public class PickAndThrow : Script
|
|||
ResetItemObject();
|
||||
}
|
||||
|
||||
if (Input.GetMouseButtonDown(Input.MouseCode.RightButton) && pc.isAiming)
|
||||
if ((Input.GetMouseButtonDown(Input.MouseCode.RightButton) || Input.GetBindingPositiveButtonDown("Drop")) && pc.isAiming)
|
||||
{
|
||||
pc.isAiming = false;
|
||||
pc.cam.FOV = Settings.cameraFOV;
|
||||
|
@ -125,7 +125,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)
|
||||
{
|
||||
|
|
|
@ -46,7 +46,7 @@ public class PlayerController : Script
|
|||
private float oldForce;
|
||||
private float maxOldVel;
|
||||
private bool sprintIncreaseOnce = false;
|
||||
|
||||
|
||||
public Vector2 axisMove { get; set; }
|
||||
|
||||
public bool isMoveKeyPress { get; set; }
|
||||
|
@ -103,7 +103,7 @@ public class PlayerController : Script
|
|||
|
||||
//Transform check
|
||||
tranform = GetComponent<Transform>();
|
||||
if(!tranform)
|
||||
if (!tranform)
|
||||
Debug.LogError("tranform is MISSING!");
|
||||
|
||||
stateMachine = AddScript<StateMachine>();
|
||||
|
@ -169,20 +169,20 @@ public class PlayerController : Script
|
|||
if (!pat)
|
||||
{
|
||||
pat = GetScript<PickAndThrow>();
|
||||
if(!pat)
|
||||
if (!pat)
|
||||
Debug.LogError("PickAndThrow is NULL!");
|
||||
}
|
||||
|
||||
if (!cam)
|
||||
{
|
||||
{
|
||||
cam = GetComponentInChildren<Camera>();
|
||||
if (pat)
|
||||
cam.FOV = Settings.cameraFOV;
|
||||
}
|
||||
if(!camArm)
|
||||
if (!camArm)
|
||||
camArm = GetComponentInChildren<CameraArm>();
|
||||
|
||||
|
||||
|
||||
|
||||
GotCaught();
|
||||
Rotation();
|
||||
|
@ -211,54 +211,79 @@ public class PlayerController : Script
|
|||
private void MoveKey()
|
||||
{
|
||||
axisMove = Vector2.Zero;
|
||||
if (Input.GetKey(Input.KeyCode.W))
|
||||
|
||||
//Forward/Backward
|
||||
Vector3 cameraAxisForward = cam.GetForward();
|
||||
cameraAxisForward.y = 0.0f;
|
||||
cameraAxisForward.Normalise();
|
||||
Vector2 vectorForward = new Vector2(cameraAxisForward.x, cameraAxisForward.z);
|
||||
vectorForward *= Input.GetBindingAxis("Vertical");
|
||||
axisMove += vectorForward;
|
||||
|
||||
//Left/Right
|
||||
Vector3 cameraAxisSide = cam.GetRight();
|
||||
cameraAxisSide.y = 0.0f;
|
||||
cameraAxisSide.Normalise();
|
||||
Vector2 vectorSide = new Vector2(cameraAxisSide.x, cameraAxisSide.z);
|
||||
vectorSide *= Input.GetBindingAxis("Horizontal");
|
||||
axisMove += vectorSide;
|
||||
|
||||
/*if (Input.GetBindingAxis("Vertical") > 0.0f)
|
||||
{
|
||||
Vector3 camerAixs = cam.GetForward();
|
||||
camerAixs.y = 0;
|
||||
camerAixs.Normalise();
|
||||
axisMove += new Vector2(camerAixs.x, camerAixs.z);
|
||||
Vector2 vectorForward = new Vector2(camerAixs.x, camerAixs.z);
|
||||
vectorForward *= Input.GetBindingAxis("Vertical");
|
||||
axisMove += vectorForward;
|
||||
}
|
||||
|
||||
if (Input.GetKey(Input.KeyCode.S))
|
||||
if (Input.GetBindingAxis("Vertical") < 0.0f)
|
||||
{
|
||||
Vector3 camerAixs = cam.GetForward();
|
||||
camerAixs.y = 0;
|
||||
camerAixs.Normalise();
|
||||
axisMove -= new Vector2(camerAixs.x, camerAixs.z);
|
||||
Vector2 vectorForward = new Vector2(camerAixs.x, camerAixs.z);
|
||||
vectorForward *= Input.GetBindingAxis("Vertical");
|
||||
axisMove += vectorForward;
|
||||
}
|
||||
|
||||
if (Input.GetKey(Input.KeyCode.A))
|
||||
if (Input.GetBindingAxis("Horizontal") < 0.0f)
|
||||
{
|
||||
Vector3 camerAixs = cam.GetRight();
|
||||
camerAixs.y = 0;
|
||||
camerAixs.Normalise();
|
||||
axisMove -= new Vector2(camerAixs.x, camerAixs.z);
|
||||
Vector2 vectorSide = new Vector2(camerAixs.x, camerAixs.z);
|
||||
vectorSide *= Input.GetBindingAxis("Horizontal");
|
||||
axisMove += vectorSide;
|
||||
}
|
||||
|
||||
if (Input.GetKey(Input.KeyCode.D))
|
||||
if (Input.GetBindingAxis("Horizontal") > 0.0f)
|
||||
{
|
||||
Vector3 camerAixs = cam.GetRight();
|
||||
camerAixs.y = 0;
|
||||
camerAixs.Normalise();
|
||||
axisMove += new Vector2(camerAixs.x, camerAixs.z);
|
||||
Vector2 vectorSide = new Vector2(camerAixs.x, camerAixs.z);
|
||||
vectorSide *= Input.GetBindingAxis("Horizontal");
|
||||
axisMove += vectorSide;
|
||||
}
|
||||
|
||||
axisMove.Normalise();
|
||||
axisMove.Normalise();*/
|
||||
isMoveKeyPress = axisMove.x != 0 || axisMove.y != 0;
|
||||
|
||||
if (isMoveKeyPress && isGrounded && !Input.GetKey(Input.KeyCode.LeftShift))
|
||||
{
|
||||
if (isMoveKeyPress && isGrounded && !Input.GetBindingPositiveButton("Sprint"))
|
||||
{
|
||||
currentState = RaccoonStates.WALKING;
|
||||
|
||||
if(stateMachine && !stateMachine.IsState(typeof(PlayerWalkState)))
|
||||
if (stateMachine && !stateMachine.IsState(typeof(PlayerWalkState)))
|
||||
stateMachine.SetState(typeof(PlayerWalkState));
|
||||
}
|
||||
|
||||
if (!isMoveKeyPress && isGrounded)
|
||||
{
|
||||
{
|
||||
currentState = RaccoonStates.IDLE;
|
||||
|
||||
if(stateMachine && !stateMachine.IsState(typeof(PlayerIdleState)))
|
||||
if (stateMachine && !stateMachine.IsState(typeof(PlayerIdleState)))
|
||||
stateMachine.SetState(typeof(PlayerIdleState));
|
||||
}
|
||||
}
|
||||
|
@ -285,7 +310,7 @@ public class PlayerController : Script
|
|||
|
||||
private void Sprint()
|
||||
{
|
||||
if (Input.GetKey(Input.KeyCode.LeftShift) && isMoveKeyPress && isGrounded)
|
||||
if (Input.GetBindingPositiveButton("Sprint") && isMoveKeyPress && isGrounded)
|
||||
{
|
||||
currentState = RaccoonStates.RUNNING;
|
||||
if (stateMachine && !stateMachine.IsState(typeof(PlayerRunState)))
|
||||
|
@ -303,12 +328,12 @@ public class PlayerController : Script
|
|||
}
|
||||
}
|
||||
|
||||
if (Input.GetKeyUp(Input.KeyCode.LeftShift))
|
||||
if (Input.GetBindingPositiveButtonUp("Sprint"))
|
||||
{
|
||||
if (isMoveKeyPress)
|
||||
{
|
||||
{
|
||||
currentState = RaccoonStates.WALKING;
|
||||
if(stateMachine && !stateMachine.IsState(typeof(PlayerWalkState)))
|
||||
if (stateMachine && !stateMachine.IsState(typeof(PlayerWalkState)))
|
||||
stateMachine.SetState(typeof(PlayerWalkState));
|
||||
}
|
||||
sprintIncreaseOnce = false;
|
||||
|
@ -321,7 +346,7 @@ public class PlayerController : Script
|
|||
{
|
||||
if (currentState == RaccoonStates.WALKING || currentState == RaccoonStates.RUNNING || currentState == RaccoonStates.IDLE)
|
||||
{
|
||||
if ( (Input.GetKeyDown(Input.KeyCode.Space) || landedOnJumpPad ) && isGrounded && rb != null)
|
||||
if ((Input.GetBindingPositiveButtonDown("Jump")|| landedOnJumpPad) && isGrounded && rb != null)
|
||||
{
|
||||
currentState = RaccoonStates.JUMP;
|
||||
if (stateMachine && !stateMachine.IsState(typeof(PlayerJumpState)))
|
||||
|
@ -340,7 +365,7 @@ public class PlayerController : Script
|
|||
}
|
||||
|
||||
if (landedOnJumpPad)
|
||||
{
|
||||
{
|
||||
v.y *= jumpPadMultiplayer;
|
||||
landedOnJumpPad = false;
|
||||
}
|
||||
|
@ -348,13 +373,13 @@ 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.GetBindingPositiveButtonUp("Jump")))
|
||||
{
|
||||
currentState = RaccoonStates.FALLING;
|
||||
if (stateMachine && !stateMachine.IsState(typeof(PlayerFallState)))
|
||||
stateMachine.SetState(typeof(PlayerFallState));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void Rotation()
|
||||
|
@ -363,7 +388,7 @@ public class PlayerController : Script
|
|||
if (isMoveKeyPress && tranform && !isAiming)
|
||||
{
|
||||
Quaternion currentRotation = tranform.LocalRotation;
|
||||
Quaternion targetRotation = Quaternion.Euler(0.0f, MathF.Atan2(axisMove.x,axisMove.y), 0.0f);
|
||||
Quaternion targetRotation = Quaternion.Euler(0.0f, MathF.Atan2(axisMove.x, axisMove.y), 0.0f);
|
||||
tranform.LocalRotation = Quaternion.Slerp(currentRotation, targetRotation, rotationFactorPerFrame * (float)Time.FixedDeltaTime);
|
||||
}
|
||||
else if (camArm && tranform && isAiming)
|
||||
|
@ -381,10 +406,10 @@ public class PlayerController : Script
|
|||
{
|
||||
//check player vel.y if its close to zero its on the ground
|
||||
if (SHADE.Math.CompareFloat(rb.LinearVelocity.y, 0.0f))
|
||||
{
|
||||
{
|
||||
isGrounded = true;
|
||||
if (currentState == RaccoonStates.FALLING)
|
||||
{
|
||||
{
|
||||
currentState = RaccoonStates.LANDED;
|
||||
if (stateMachine && !stateMachine.IsState(typeof(PlayerLandState)))
|
||||
stateMachine.SetState(typeof(PlayerLandState));
|
||||
|
|
|
@ -19,6 +19,8 @@ namespace SHADE_Scripting
|
|||
public float pitchUpperClamp = 45.0f;
|
||||
public float pitchLowerClamp = 5.0f;
|
||||
|
||||
public float cameraSensitivity = 400.0f;
|
||||
|
||||
protected override void awake()
|
||||
{
|
||||
AddComponent<Transform>();
|
||||
|
@ -50,7 +52,14 @@ namespace SHADE_Scripting
|
|||
CameraArm arm = GetComponent<CameraArm>();
|
||||
if (arm)
|
||||
{
|
||||
Vector2 vel = Input.GetMouseVelocity();
|
||||
Vector2 vel = new Vector2();
|
||||
if (!Input.ControllerInUse)
|
||||
vel = Input.GetMouseVelocity();
|
||||
else
|
||||
{
|
||||
vel.x = (float)Input.GetBindingAxis("Controller Look Horizontal") * cameraSensitivity;
|
||||
vel.y = (float)Input.GetBindingAxis("Controller Look Vertical") * cameraSensitivity;
|
||||
}
|
||||
if(inverseYControls)
|
||||
arm.Pitch -= vel.y * turnSpeedPitch * Time.DeltaTimeF;
|
||||
else
|
||||
|
|
|
@ -12,6 +12,9 @@ public class MainMenu : Script
|
|||
|
||||
protected override void awake()
|
||||
{
|
||||
//Load the bindings
|
||||
Input.LoadBindings();
|
||||
|
||||
AudioHandler.audioClipHandlers["BGMMainMenu"] = Audio.CreateAudioClip("event:/Music/main_menu");
|
||||
//AudioHandler.audioClipHandlers["SFXMouseDownElement"] = Audio.CreateAudioClip("event:/UI/mouse_down_element");
|
||||
//AudioHandler.audioClipHandlers["SFXUISuccess"] = Audio.CreateAudioClip("event:/UI/success");
|
||||
|
|
Loading…
Reference in New Issue