-Modified mountain (may need more changes later)

-Added full controller support for all abillities that will be in the game
(grapple is currently set to x)
This commit is contained in:
Evan Nydahl
2021-12-01 15:38:24 -06:00
parent 02410a642f
commit 20db245902
20 changed files with 434 additions and 606 deletions

View File

@@ -34,7 +34,8 @@ public class dGrapplingHook : NetworkBehaviour
{
//if (!IsLocalPlayer) { return; }
if (Input.GetKeyDown(KeyCode.E)) //If grapple button is hit
//if E or left face gamepad button is pressed is slightly pressed
if (Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.JoystickButton2)) //If grapple button is hit
{
if (!isGrappled) //If we are not grappling
{
@@ -60,7 +61,8 @@ public class dGrapplingHook : NetworkBehaviour
{
Debug.DrawRay(gameObject.transform.position, (hookPoint.transform.position - gameObject.transform.position)); //Visual of line
if (Input.GetKey(KeyCode.LeftShift)) //Extend hook
//if left shift or left bumper held down
if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.JoystickButton4)) //Extend hook
{
ropeLength += climbRate * Time.deltaTime;
if (ropeLength > maxGrappleDistance)
@@ -69,7 +71,7 @@ public class dGrapplingHook : NetworkBehaviour
}
//Debug.Log(ropeLength.ToString());
}
if (Input.GetKey(KeyCode.RightShift)) // Retract Hook
if (Input.GetKey(KeyCode.RightShift) || Input.GetKey(KeyCode.JoystickButton5)) // Retract Hook
{
ropeLength -= climbRate * Time.deltaTime;
if (ropeLength < 5)

View File

@@ -30,7 +30,8 @@ public class dKickController : NetworkBehaviour
void Kick(){
//Note: when we merge this into PlayerMovement, we may want to change isgrounded to our
//custom is grounded
if (Input.GetKeyDown(KeyCode.F) && isKicking == false && characterController.isGrounded == false)
//If F is pressed or gamepad right trigger is pulled
if ((Input.GetKeyDown(KeyCode.F) || Input.GetAxis("Kick") != 0) && isKicking == false && characterController.isGrounded == false)
{
Debug.Log("dive");
// if kicking in air, kick until grounded (maybe add some foward momentum if needeD)
@@ -39,13 +40,14 @@ public class dKickController : NetworkBehaviour
leg.SetActive(true);
}
//otherwise do ground kick for .3 seconds
else if (Input.GetKeyDown(KeyCode.F) && isKicking == false){
else if ((Input.GetKeyDown(KeyCode.F) || Input.GetAxis("Kick") != 0) && isKicking == false){
Debug.Log("kick");
StartCoroutine(Kicking(.3f));
}
//once dive kick touches ground, set back to normal state
if(characterController.isGrounded == true && isDiveKicking == true){
if (characterController.isGrounded == true && isDiveKicking == true)
{
isDiveKicking = false;
isKicking = false;
leg.SetActive(false);

View File

@@ -258,7 +258,7 @@ public class dPlayerMovement : NetworkBehaviour
//Jump Function
private void Jump()
{
//If space is pressed apply an upwards force to the player
//If space/south gamepad button is pressed apply an upwards force to the player
if (Input.GetAxis("Jump") != 0 && !jumpPressed && curJumpNum + 1 < pStats.JumpNum && !isSliding)
{
AddImpact(transform.up, pStats.JumpPow);
@@ -273,7 +273,7 @@ public class dPlayerMovement : NetworkBehaviour
curJumpNum = 0;
}
//If space isn't being pressed then jump is false
//If space/south face gamepad button isn't being pressed then jump is false
if (Input.GetAxis("Jump") == 0) jumpPressed = false;
}
@@ -304,16 +304,30 @@ public class dPlayerMovement : NetworkBehaviour
//Camera and Player Rotation
private void Rotation()
{
Vector3 lastCamPos = new Vector3(0,0,0);
Vector3 rotOffset = transform.localEulerAngles;
if(moveController.enabled){
transform.parent.Rotate(Vector3.up * sensitivity * Time.deltaTime * Input.GetAxis("Mouse X"));
//if input is received from Mouse X
if (Input.GetAxis("Mouse X") != 0)
{
transform.parent.Rotate(Vector3.up * sensitivity * Time.deltaTime * Input.GetAxis("Mouse X"));
}
//if input is received from right analog stick (horizontal)
else if (Input.GetAxis("HorizontalCam") != 0)
{
transform.parent.Rotate(Vector3.up * sensitivity * Time.deltaTime * Input.GetAxis("HorizontalCam"));
}
camRotation.x -= Input.GetAxis("Mouse Y") * sensitivity * Time.deltaTime;
camRotation.x = Mathf.Clamp(camRotation.x, minAngle, maxAngle);
cam.transform.localEulerAngles = camRotation;
//if input is if input is received from Mouse Y
if (Input.GetAxis("Mouse Y") != 0)
{
camRotation.x -= Input.GetAxis("Mouse Y") * sensitivity * Time.deltaTime;
camRotation.x = Mathf.Clamp(camRotation.x, minAngle, maxAngle);
cam.transform.localEulerAngles = camRotation;
}
//if input is received from right analog stick (vertical)
else if (Input.GetAxis("VerticalTurn") != 0)
{
camRotation.x -= Input.GetAxis("VerticalTurn") * sensitivity * Time.deltaTime;
camRotation.x = Mathf.Clamp(camRotation.x, minAngle, maxAngle);
cam.transform.localEulerAngles = camRotation;
}
}
@@ -431,7 +445,8 @@ public class dPlayerMovement : NetworkBehaviour
//Slide Function
private void Slide(){
if (Input.GetKey(KeyCode.Q)){
//if the q button or the east face button on gamepad is held down
if (Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)) {
qDown = true;
if (isSliding == false){
originalTraction = pStats.Traction;

View File

@@ -1,132 +0,0 @@
// GENERATED AUTOMATICALLY FROM 'Assets/Scripts/PlayerScripts/MovementAbilities/GamePadControlls.inputactions'
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Utilities;
public class @GamePadControlls : IInputActionCollection, IDisposable
{
public InputActionAsset asset { get; }
public @GamePadControlls()
{
asset = InputActionAsset.FromJson(@"{
""name"": ""GamePadControlls"",
""maps"": [
{
""name"": ""Runner"",
""id"": ""5b72a223-d8e7-4904-bda9-b7bc5bf92850"",
""actions"": [
{
""name"": ""Jump"",
""type"": ""Button"",
""id"": ""bd111e05-cd62-4634-ac88-eb948971f528"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """"
}
],
""bindings"": [
{
""name"": """",
""id"": ""9fde690f-bb27-4b3c-a7e4-4354283ff9da"",
""path"": ""<Gamepad>/buttonSouth"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Jump"",
""isComposite"": false,
""isPartOfComposite"": false
}
]
}
],
""controlSchemes"": []
}");
// Runner
m_Runner = asset.FindActionMap("Runner", throwIfNotFound: true);
m_Runner_Jump = m_Runner.FindAction("Jump", throwIfNotFound: true);
}
public void Dispose()
{
UnityEngine.Object.Destroy(asset);
}
public InputBinding? bindingMask
{
get => asset.bindingMask;
set => asset.bindingMask = value;
}
public ReadOnlyArray<InputDevice>? devices
{
get => asset.devices;
set => asset.devices = value;
}
public ReadOnlyArray<InputControlScheme> controlSchemes => asset.controlSchemes;
public bool Contains(InputAction action)
{
return asset.Contains(action);
}
public IEnumerator<InputAction> GetEnumerator()
{
return asset.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public void Enable()
{
asset.Enable();
}
public void Disable()
{
asset.Disable();
}
// Runner
private readonly InputActionMap m_Runner;
private IRunnerActions m_RunnerActionsCallbackInterface;
private readonly InputAction m_Runner_Jump;
public struct RunnerActions
{
private @GamePadControlls m_Wrapper;
public RunnerActions(@GamePadControlls wrapper) { m_Wrapper = wrapper; }
public InputAction @Jump => m_Wrapper.m_Runner_Jump;
public InputActionMap Get() { return m_Wrapper.m_Runner; }
public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); }
public bool enabled => Get().enabled;
public static implicit operator InputActionMap(RunnerActions set) { return set.Get(); }
public void SetCallbacks(IRunnerActions instance)
{
if (m_Wrapper.m_RunnerActionsCallbackInterface != null)
{
@Jump.started -= m_Wrapper.m_RunnerActionsCallbackInterface.OnJump;
@Jump.performed -= m_Wrapper.m_RunnerActionsCallbackInterface.OnJump;
@Jump.canceled -= m_Wrapper.m_RunnerActionsCallbackInterface.OnJump;
}
m_Wrapper.m_RunnerActionsCallbackInterface = instance;
if (instance != null)
{
@Jump.started += instance.OnJump;
@Jump.performed += instance.OnJump;
@Jump.canceled += instance.OnJump;
}
}
}
public RunnerActions @Runner => new RunnerActions(this);
public interface IRunnerActions
{
void OnJump(InputAction.CallbackContext context);
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 3698cf5288c74ad41ba892329e2fb719
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,33 +0,0 @@
{
"name": "GamePadControlls",
"maps": [
{
"name": "Runner",
"id": "5b72a223-d8e7-4904-bda9-b7bc5bf92850",
"actions": [
{
"name": "Jump",
"type": "Button",
"id": "bd111e05-cd62-4634-ac88-eb948971f528",
"expectedControlType": "Button",
"processors": "",
"interactions": ""
}
],
"bindings": [
{
"name": "",
"id": "9fde690f-bb27-4b3c-a7e4-4354283ff9da",
"path": "<Gamepad>/buttonSouth",
"interactions": "",
"processors": "",
"groups": "",
"action": "Jump",
"isComposite": false,
"isPartOfComposite": false
}
]
}
],
"controlSchemes": []
}

View File

@@ -1,14 +0,0 @@
fileFormatVersion: 2
guid: c3d6a5f3edd2f9d4693efbb2085dde9c
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3}
generateWrapperCode: 1
wrapperCodePath:
wrapperClassName:
wrapperCodeNamespace:

View File

@@ -34,7 +34,7 @@ public class GrapplingHook : NetworkBehaviour
{
//if (!IsLocalPlayer) { return; }
if (Input.GetKeyDown(KeyCode.E)) //If grapple button is hit
if (Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.JoystickButton2)) //If grapple button is hit
{
if (!isGrappled) //If we are not grappling
{
@@ -59,8 +59,8 @@ public class GrapplingHook : NetworkBehaviour
if (isGrappled)
{
Debug.DrawRay(gameObject.transform.position, (hookPoint.transform.position - gameObject.transform.position)); //Visual of line
if (Input.GetKey(KeyCode.LeftShift)) //Extend hook
if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.JoystickButton4)) //Extend hook
{
ropeLength += climbRate * Time.deltaTime;
if (ropeLength > maxGrappleDistance)
@@ -69,7 +69,7 @@ public class GrapplingHook : NetworkBehaviour
}
//Debug.Log(ropeLength.ToString());
}
if (Input.GetKey(KeyCode.RightShift)) // Retract Hook
if (Input.GetKey(KeyCode.RightShift) || Input.GetKey(KeyCode.JoystickButton5)) // Retract Hook
{
ropeLength -= climbRate * Time.deltaTime;
if (ropeLength < 5)

View File

@@ -30,7 +30,8 @@ public class KickController : NetworkBehaviour
void Kick(){
//Note: when we merge this into PlayerMovement, we may want to change isgrounded to our
//custom is grounded
if (Input.GetKeyDown(KeyCode.F) && isKicking == false && characterController.isGrounded == false)
//If F is pressed or gamepad right trigger is pulled
if ((Input.GetKeyDown(KeyCode.F) || Input.GetAxis("Kick") != 0) && isKicking == false && characterController.isGrounded == false)
{
Debug.Log("dive");
// if kicking in air, kick until grounded (maybe add some foward momentum if needeD)
@@ -39,7 +40,7 @@ public class KickController : NetworkBehaviour
leg.SetActive(true);
}
//otherwise do ground kick for .3 seconds
else if (Input.GetKeyDown(KeyCode.F) && isKicking == false){
else if (( Input.GetKeyDown(KeyCode.F) || Input.GetAxis("Kick") != 0) && isKicking == false){
Debug.Log("kick");
StartCoroutine(Kicking(.3f));
}

View File

@@ -3,12 +3,10 @@ using System.Collections.Generic;
using MLAPI;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.InputSystem;
public class PlayerMovement : NetworkBehaviour
{
//Controller object
new GamePadControlls controler;
//Scripts
public PlayerStats pStats;
@@ -90,8 +88,8 @@ public class PlayerMovement : NetworkBehaviour
capCol = GetComponent<CapsuleCollider>();
pStats = GetComponent<PlayerStats>();
parentObj = transform.parent.gameObject;
controler = new GamePadControlls();
controler.Runner.Enable();
capCol.enabled = false;
//Wallrun
@@ -295,13 +293,30 @@ public class PlayerMovement : NetworkBehaviour
Vector3 lastCamPos = new Vector3(0,0,0);
Vector3 rotOffset = transform.localEulerAngles;
if(moveController.enabled){
transform.parent.Rotate(Vector3.up * sensitivity * Time.deltaTime * Input.GetAxis("Mouse X"));
//if input is received from Mouse X
if (Input.GetAxis("Mouse X") != 0){
transform.parent.Rotate(Vector3.up * sensitivity * Time.deltaTime * Input.GetAxis("Mouse X"));
}
//if input is received from right analog stick (horizontal)
else if(Input.GetAxis("HorizontalCam") != 0){
transform.parent.Rotate(Vector3.up * sensitivity * Time.deltaTime * Input.GetAxis("HorizontalCam"));
}
camRotation.x -= Input.GetAxis("Mouse Y") * sensitivity * Time.deltaTime;
camRotation.x = Mathf.Clamp(camRotation.x, minAngle, maxAngle);
cam.transform.localEulerAngles = camRotation;
//if input is if input is received from Mouse Y
if (Input.GetAxis("Mouse Y") != 0)
{
camRotation.x -= Input.GetAxis("Mouse Y") * sensitivity * Time.deltaTime;
camRotation.x = Mathf.Clamp(camRotation.x, minAngle, maxAngle);
cam.transform.localEulerAngles = camRotation;
}
//if input is received from right analog stick (vertical)
else if (Input.GetAxis("VerticalTurn") != 0){
camRotation.x -= Input.GetAxis("VerticalTurn") * sensitivity * Time.deltaTime;
camRotation.x = Mathf.Clamp(camRotation.x, minAngle, maxAngle);
cam.transform.localEulerAngles = camRotation;
}
}
}
@@ -419,7 +434,7 @@ public class PlayerMovement : NetworkBehaviour
//Slide Function
private void Slide(){
if (Input.GetKey(KeyCode.Q)){
if (Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)){
qDown = true;
if (isSliding == false){
originalTraction = pStats.Traction;

View File

@@ -91,7 +91,7 @@ public class PlayerStats : MonoBehaviour
}
//If The Player Has Grapple
private bool hasGrapple = false;
private bool hasGrapple = true;
public bool HasGrapple{
get{ return hasGrapple; }
set{ hasGrapple = value; }