Merge branch 'FixGlideJump'

This commit is contained in:
Melbyj1125 2022-04-04 11:45:28 -05:00
commit 3f1e2b8a51
38 changed files with 178 additions and 644 deletions

View File

@ -981,7 +981,7 @@ MonoBehaviour:
jumpNum: 2
traction: 5
curTraction: 0
kickPow: 300
kickPow: 500
recovTime: 3
playerGrav: 200
gravVel: 0
@ -1121,6 +1121,7 @@ MonoBehaviour:
mSM: {fileID: 0}
curJumpNum: 0
jumpHeld: 0
canJump: 1
coyJumpTimer: 0.1
curCoyJumpTimer: 0.13
lowJumpMultiplier: 0.001
@ -1128,16 +1129,11 @@ MonoBehaviour:
isGrounded: 0
groundCheckDistance: 0.05
isWallRunning: 0
maxGrabDistance: 50
hookPoint: {fileID: 0}
hookPoints: []
hookPointIndex: 0
distance: 0
maxGrappleDistance: 25
maxSwingSpeed: 50
minSwingSpeed: 20
swingAcc: 3
maxSwingMom: 60
release: 0
tempRelease: {x: 0, y: 0, z: 0}
lerpRelease: {x: 0, y: 0, z: 0}

View File

@ -2317,8 +2317,8 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1405946429}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 36.3, y: 22.3, z: 13.7}
m_LocalScale: {x: 10, y: 10, z: 10}
m_LocalPosition: {x: 36.3, y: 14.7, z: 13.7}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 5
@ -3293,6 +3293,18 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 1707207228499037468, guid: 0ea305f96ab853340bb9f0ed320dac08, type: 3}
propertyPath: hasGlider
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1707207228499037468, guid: 0ea305f96ab853340bb9f0ed320dac08, type: 3}
propertyPath: hasGrapple
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2088235644774667867, guid: 0ea305f96ab853340bb9f0ed320dac08, type: 3}
propertyPath: m_LocalPosition.y
value: 1.6
objectReference: {fileID: 0}
- target: {fileID: 5759777694531189237, guid: 0ea305f96ab853340bb9f0ed320dac08, type: 3}
propertyPath: m_RootOrder
value: 13

View File

@ -29,7 +29,7 @@ public class dAerialGroundedState : dAerialBaseState
//can grapple and in state that allows grapple
else if(aSM.CheckGrapple() && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.CrouchState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
aSM.SwitchState(aSM.GrappleGroundedState);
aSM.SwitchState(aSM.GrappleAirState);
}
}

View File

@ -5,264 +5,94 @@ using UnityEngine;
public class dAerialGrappleAirState : dAerialBaseState
{
bool spaceHeld = true;
float ropeLength; // current rope length
float inclinationAngle; // inclination angle
float theta = -1; // theta for rope angle
Vector3 hookPointRight; // right vector of the hook point
Vector3 curXZDir; // current straight line between player and hook point ignoring y axis
Vector3 oldXZDir; // old straight line between player and hook point ignoring y axis
Vector3 initialForceDirection;
float distanceBeneathHook = -3f;
float distanceAfterHook = 8f;
Vector3 desiredPosition;
bool pointReached = false;
float initialForcePower = 4;
Vector3 swingDirection; // Swing direction
float swingSpeed = 10; // cur swing speed
Vector3 tensionDirection; // tension direction
float tensionForce; // tension force amplifier
float swingMom; // swing Mom amplifier
float oldSwingMom; // old swing Momentum amplifier
Vector3 momDirection; // momentum direction
Vector3 tensionMomDirection; // tension momentum direction
float defaultGraceTimer = 1.0f; // default timer
float graceTimer; // grace period at the end of the swing so the player has time to let go
bool swingGrace = true; // is the grace timer over
public override void EnterState(dAerialStateManager aSM, dAerialBaseState previousState){
distanceBeneathHook = -3f;
distanceAfterHook = 8f;
pointReached = false;
initialForcePower = 4;
//refresh jump number
aSM.curJumpNum = 0;
aSM.release = false;
Vector3 updatedYHookPoint = new Vector3(aSM.hookPoint.transform.position.x, aSM.hookPoint.transform.position.y - distanceBeneathHook, aSM.hookPoint.transform.position.z);
Vector3 updatedXHookPointDirection = (new Vector3(aSM.transform.position.x, 0, aSM.transform.position.z) - new Vector3(aSM.hookPoint.transform.position.x, 0, aSM.hookPoint.transform.position.z)).normalized;
desiredPosition = updatedYHookPoint + (updatedXHookPointDirection * -distanceAfterHook);
//rope length limit
ropeLength = Vector3.Distance(aSM.transform.position, aSM.hookPoint.transform.position);
if(ropeLength > aSM.maxGrappleDistance){
ropeLength = aSM.maxGrappleDistance;
}
initialForceDirection = desiredPosition - aSM.transform.position;
initialForceDirection = initialForceDirection.normalized;
//old and cur direction vector for player to hookpoint
oldXZDir = (new Vector3(aSM.hookPoint.transform.position.x,0,aSM.hookPoint.transform.position.z) - new Vector3(aSM.transform.position.x,0,aSM.transform.position.z)).normalized;
curXZDir = (new Vector3(aSM.hookPoint.transform.position.x,0,aSM.hookPoint.transform.position.z) - new Vector3(aSM.transform.position.x,0,aSM.transform.position.z)).normalized;
aSM.postForceDirection = new Vector3(initialForceDirection.x, 0, initialForceDirection.z).normalized;
aSM.currentForcePower = initialForcePower;
//swing momentum calculation
swingMom = CalculateSwingMom(aSM.mSM.driftVel.magnitude * 50f, aSM);
oldSwingMom = swingMom;
//Initialize variables
aSM.pStats.GravVel = -1; // grav vel is adjusted so things work
aSM.release = false; // player hasn't released
aSM.lerpRelease = Vector3.zero; // reset lerp release
spaceHeld = true;
graceTimer = defaultGraceTimer; //sets grace timer
}
public override void ExitState(dAerialStateManager aSM, dAerialBaseState nextState){
//If not going into grapple grounded state
if(nextState != aSM.GrappleGroundedState){
aSM.release = true;
aSM.pStats.GravVel = 0;
aSM.forceDirection = Vector3.zero;
if(nextState == aSM.GroundedState || nextState == aSM.WallRunState){
aSM.release = false;
}
//If going into grapple grounded state
else{
aSM.pStats.GravVel = 0;
aSM.forceDirection = Vector3.zero;
aSM.release = true;
aSM.pStats.GravVel = 10;
}
}
public override void UpdateState(dAerialStateManager aSM){
//if pressing E or ragdolling then falling
if(((Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.JoystickButton2)) && !aSM.eHeld && !aSM.pStats.IsPaused) || (aSM.mSM.currentState == aSM.mSM.RagdollState)){
aSM.SwitchState(aSM.FallingState);
if(pointReached){
//if grounded at when the point is reached then goto grounded state
if(aSM.isGrounded){
aSM.SwitchState(aSM.GroundedState);
}
else if(!aSM.isGrounded){
aSM.SwitchState(aSM.FallingState);
}
//if wallrunning then wallrun
else if(aSM.isWallRunning){
aSM.SwitchState(aSM.WallRunState);
}
}
else if((Input.GetKeyUp(KeyCode.E) || Input.GetKeyUp(KeyCode.JoystickButton2)) && aSM.eHeld){
aSM.eHeld = false;
}
//if pressing Jump then jump
else if(Input.GetButton("Jump") && !spaceHeld && !aSM.pStats.IsPaused){
aSM.SwitchState(aSM.JumpingState);
}
else if(!(Input.GetButton("Jump")) && spaceHeld){
spaceHeld = false;
}
//if grounded then grapple grounded
else if(aSM.isGrounded){
aSM.SwitchState(aSM.GrappleGroundedState);
}
//if wallrunning then wallrun
else if(aSM.isWallRunning){
aSM.SwitchState(aSM.WallRunState);
}
}
public override void FixedUpdateState(dAerialStateManager aSM){
////////ADD A LINE RENDERER WHEN WE GET THE HAND MODEL
//Draw Line between player and hookpoint for debug purposes
Debug.DrawRay(aSM.transform.position, (aSM.hookPoint.transform.position - aSM.transform.position)); //Visual of line
Debug.DrawRay(aSM.transform.position, initialForceDirection); //Visual of line
//Calculate tether force direction based on hookpoint
if (Vector3.Distance(aSM.transform.position, aSM.hookPoint.transform.position) >= ropeLength )
{
aSM.forceDirection = CalculateForceDirection(1, aSM.pStats.GravVel, aSM.hookPoint.transform.position, aSM) + RopeLengthOffset(aSM.hookPoint.transform.position, Vector3.Distance(aSM.transform.position, aSM.hookPoint.transform.position), aSM);
Vector3 tempForceDir = desiredPosition - aSM.transform.position;
tempForceDir = tempForceDir.normalized;
tempForceDir = new Vector3(tempForceDir.x,0,tempForceDir.z).normalized;
if((aSM.postForceDirection - tempForceDir).magnitude >= .1f && !pointReached){
pointReached = true;
}
else{
aSM.forceDirection = Vector3.zero;
}
//Move player based on their inputs
aSM.moveController.Move(SwingMoveController(aSM));
//if Swing Momentum isn't zero then move player
if(swingMom != 0){
aSM.moveController.Move(CalculateMomentumDirection(aSM.pStats.GravVel, aSM.hookPoint.transform.position, aSM));
swingMom -= .5f;
}
if(swingMom<0) swingMom = 0;
//Calculate temp release at every position
aSM.tempRelease = CalculateSwingReleaseForce();
//Apply default gravity
aSM.GravityCalculation(aSM.pStats.PlayerGrav);
}
//Calculate the tether direction vector and how much force that vector needs
Vector3 CalculateForceDirection(float mass, float g, Vector3 hPoint, dAerialStateManager aSM){
//tension direction and angle calculation
tensionDirection = (hPoint - aSM.transform.position).normalized;
inclinationAngle = Vector3.Angle((aSM.transform.position - hPoint).normalized, -aSM.transform.up);
theta = Mathf.Deg2Rad * inclinationAngle;
if(theta<=.1) theta = 0;
//How much force the tension needs
tensionForce = mass * -g * Mathf.Cos(theta);
//force direction calculation based on tension direction and force
Vector3 fDirection = tensionDirection * tensionForce;
//return force direction
return fDirection;
}
Vector3 CalculateMomentumDirection(float g, Vector3 hPoint, dAerialStateManager aSM){
tensionMomDirection = (hPoint - aSM.transform.position).normalized;
hookPointRight = Vector3.Cross(oldXZDir, aSM.transform.up).normalized;
momDirection = -1 * Vector3.Cross(hookPointRight, tensionMomDirection).normalized;
//if player is on the other side of hookpoint and swingMom is lower then update oldXZDir
if(oldXZDir != curXZDir && swingMom <= (oldSwingMom*(.75f))){
if(graceTimer >= 0){
swingGrace = false;
graceTimer -= .1f;
}
else{
oldSwingMom = swingMom;
oldXZDir = (new Vector3(aSM.hookPoint.transform.position.x,0,aSM.hookPoint.transform.position.z) - new Vector3(aSM.transform.position.x,0,aSM.transform.position.z)).normalized;
swingGrace = true;
graceTimer = defaultGraceTimer;
}
if(!pointReached){
aSM.moveController.Move(initialForceDirection * initialForcePower);
aSM.GravityCalculation(0);
aSM.pStats.GravVel = 0;
}
else{
//currentForcePower;
aSM.GravityCalculation(aSM.pStats.PlayerGrav);
}
//current line between hookpoint and player
curXZDir = (new Vector3(hPoint.x,0,hPoint.z) - new Vector3(aSM.transform.position.x,0,aSM.transform.position.z)).normalized;
Debug.DrawRay(aSM.transform.position, momDirection * Time.deltaTime* 100, Color.green);
//return momentum dir * mom force
return (momDirection * Time.deltaTime * swingMom);
}
//Calculates the players initial swing momentum using their height and their current velocity
float CalculateSwingMom(float playerSpeed, dAerialStateManager aSM){
//Calculate the players height compared to the lowest point in the swing
float swingHeight = aSM.transform.position.y - (aSM.hookPoint.transform.position.y - ropeLength);
if(swingHeight <= 1){
swingHeight = 1;
}
//calculates swing momentum based on height ands speed
float sMom = playerSpeed + (swingHeight * 3f);
if(sMom > aSM.maxSwingMom){
sMom = aSM.maxSwingMom;
}
//returns swing momentum
return sMom;
}
//Special movement for the player while they swing
Vector3 SwingMoveController(dAerialStateManager aSM){
//WASD input
float inputVert = Input.GetAxis("Vertical");
float inputHor = Input.GetAxis("Horizontal");
//input is zero when nothing is pressed to prevent button easing values
if((!Input.GetKey(KeyCode.W) && !Input.GetKey(KeyCode.S))) inputVert = 0;
if((!Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.D))) inputHor = 0;
//Swingspeed build up
if((inputVert != 0 || inputHor != 0) && swingSpeed < aSM.maxSwingSpeed){
swingSpeed += aSM.swingAcc;
}
else if((inputVert != 0 || inputHor != 0) && swingSpeed >= aSM.maxSwingSpeed){
swingSpeed = aSM.maxSwingSpeed;
}
else if((inputVert == 0 && inputHor == 0)){
swingSpeed = aSM.minSwingSpeed;
}
//Swing direction based on player input
swingDirection = Vector3.Cross(tensionDirection, ((aSM.transform.right * -inputVert) + (aSM.transform.forward * inputHor))).normalized;
//Swing movement with swing speed added
Vector3 swingMovement = (swingDirection * Time.deltaTime * swingSpeed);
//returns swing movement vector
return (swingMovement);
}
Vector3 RopeLengthOffset(Vector3 hPoint, float curDistance, dAerialStateManager aSM){
//How powerful our offset movement has to be
float offsetPower = ((curDistance - ropeLength) * 200f);
//The direction we need to apply force to offset when the rope gets lengthened beyond the necessary point
Vector3 tenDirOffset = (hPoint - aSM.transform.position).normalized;
//returns rope offset direction * power
return tenDirOffset * offsetPower * Time.deltaTime;
}
Vector3 CalculateSwingReleaseForce(){
//Swing release direction
Vector3 releaseSwingForceDirection = momDirection * ((swingMom) + 10);
releaseSwingForceDirection = new Vector3(releaseSwingForceDirection.x,0,releaseSwingForceDirection.z);
//if swingMom is low there is no release force
if(swingMom < 2){
return Vector3.zero;
}
//return swing release direction
return releaseSwingForceDirection * Time.deltaTime;
}
}

View File

@ -1,46 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class dAerialGrappleGroundedState : dAerialBaseState
{
public override void EnterState(dAerialStateManager aSM, dAerialBaseState previousState){
aSM.release = false; // release is false when grounded
}
public override void ExitState(dAerialStateManager aSM, dAerialBaseState nextState){
}
public override void UpdateState(dAerialStateManager aSM){
//if E is pressed or ragdolling then grounded
if(((Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.JoystickButton2)) && !aSM.eHeld && !aSM.pStats.IsPaused) || (aSM.mSM.currentState == aSM.mSM.RagdollState)){
aSM.SwitchState(aSM.GroundedState);
}
else if((Input.GetKeyUp(KeyCode.E) || Input.GetKeyUp(KeyCode.JoystickButton2)) && aSM.eHeld){
aSM.eHeld = false;
}
//if not grounded and gravVel < 0 then grapple air
else if(!aSM.isGrounded && aSM.pStats.GravVel < 0){
aSM.SwitchState(aSM.GrappleAirState);
}
//if distance between player and hookpoint is too far then grounded
else if(Vector3.Distance(aSM.transform.position, aSM.hookPoint.transform.position) > aSM.maxGrappleDistance){
aSM.SwitchState(aSM.GroundedState);
}
}
public override void FixedUpdateState(dAerialStateManager aSM){
Debug.DrawRay(aSM.transform.position, (aSM.hookPoint.transform.position - aSM.transform.position)); //Visual of line
//Default gravity calculation
aSM.GravityCalculation(aSM.pStats.PlayerGrav);
}
}

View File

@ -22,7 +22,6 @@ public class dAerialStateManager : NetworkBehaviour
public dAerialWallIdleState WallIdleState = new dAerialWallIdleState();
//Grappling States
public dAerialGrappleGroundedState GrappleGroundedState = new dAerialGrappleGroundedState();
public dAerialGrappleAirState GrappleAirState = new dAerialGrappleAirState();
////
@ -45,6 +44,7 @@ public class dAerialStateManager : NetworkBehaviour
//Jump Variables
public int curJumpNum; // current Jumps Used
public bool jumpHeld; // Jump is Held
public bool canJump = true; // can the player jump
bool jumpPressed; // Jamp was pressed
public float coyJumpTimer = 0.1f; // Default Coyote Jump time
public float curCoyJumpTimer = 0.1f; // current Coyote Jump time
@ -84,21 +84,14 @@ public class dAerialStateManager : NetworkBehaviour
Vector3 impact = Vector3.zero; // Impact Vector
//Grapple Variables
public float maxGrabDistance = 50;// Max Distance can cast grapple
float maxGrabDistance = 25;// Max Distance can cast grapple
public GameObject hookPoint; // Actual Hook points
public GameObject[] hookPoints; // Hook point list
public int hookPointIndex; // Hook point Index
public float distance; // distance of hookpoints
public float maxGrappleDistance = 25; // Max Rope Length
public float maxSwingSpeed = 50; // max swing speed
public float minSwingSpeed = 20; // min swing speed
public float swingAcc = 3f; // swing acceleration
public float maxSwingMom = 60; // max swing momentum
public bool release = false; // has player ungrappled
public Vector3 tempRelease; // temporary release force vector
public Vector3 lerpRelease; // lerped release force vector
public Vector3 forceDirection; // force direction vector
public bool eHeld; // is e being held
public Vector3 postForceDirection; // force direction vector
public float currentForcePower = 0;
////
void Awake(){
@ -255,15 +248,7 @@ public class dAerialStateManager : NetworkBehaviour
//Actually applies the downwards movement
void DownwardMovement(){
Vector3 moveY = new Vector3(0,pStats.GravVel,0) * Time.deltaTime;
if(currentState == GrappleAirState){
moveY = (new Vector3(0,pStats.GravVel,0) + forceDirection) * Time.deltaTime;
}
moveController.Move(moveY);
}
//applies Jump values and Variables
@ -278,7 +263,7 @@ public class dAerialStateManager : NetworkBehaviour
curJumpNum = 0;
}
else{
pStats.GravVel = pStats.JumpPow;
pStats.GravVel = pStats.JumpPow;
}
@ -300,7 +285,7 @@ public class dAerialStateManager : NetworkBehaviour
if(jumpHeld) curCoyJumpTimer = 0;
//If space/south face gamepad button isn't being pressed then jump is false
if (Input.GetAxis("Jump") == 0){
if (!Input.GetButton("Jump")){
jumpHeld = false;
}
@ -481,11 +466,12 @@ public class dAerialStateManager : NetworkBehaviour
if(!pStats.IsPaused){
if ((Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.JoystickButton2)) && pStats.HasGrapple) //If grapple button is hit
{
Debug.Log("Checking Hooks");
hookPointIndex = FindHookPoint(); //Find the nearest hook point within max distance
if (hookPointIndex != -1) //If there is a hookpoint
{
Debug.Log("Found Hook");
hookPoint = hookPoints[hookPointIndex]; //The point we are grappling from
eHeld = true;
return true;
}
}
@ -512,9 +498,10 @@ public class dAerialStateManager : NetworkBehaviour
//lerped grapple release force and dissipation of it
public void GrappleReleaseForce(){
if(release){
lerpRelease = Vector3.Lerp(lerpRelease, tempRelease, 9f * Time.deltaTime);
tempRelease *= .98f;
moveController.Move(lerpRelease);
currentForcePower *= .90f;
moveController.Move(postForceDirection * currentForcePower);
if(currentForcePower < .05) release = false;
}
}
////

View File

@ -22,7 +22,7 @@ public class dMoveIdleState : dMoveBaseState
}
//If Q or joystick button1 crouch state
else if((Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)) && (mSM.aSM.currentState != mSM.aSM.FallingState && mSM.aSM.currentState != mSM.aSM.WallRunState && mSM.aSM.currentState != mSM.aSM.WallIdleState && mSM.aSM.currentState != mSM.aSM.GrappleGroundedState) && !mSM.pStats.IsPaused){
else if((Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)) && (mSM.aSM.currentState != mSM.aSM.FallingState && mSM.aSM.currentState != mSM.aSM.WallRunState && mSM.aSM.currentState != mSM.aSM.WallIdleState) && !mSM.pStats.IsPaused){
mSM.SwitchState(mSM.CrouchState);
}
}

View File

@ -26,7 +26,7 @@ public class dMoveJogState : dMoveBaseState
}
//move to slide if Q or JoystickButton1
else if((Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)) && (mSM.aSM.currentState != mSM.aSM.FallingState && mSM.aSM.currentState != mSM.aSM.WallRunState && mSM.aSM.currentState != mSM.aSM.WallIdleState && mSM.aSM.currentState != mSM.aSM.GrappleGroundedState) && !mSM.pStats.IsPaused){
else if((Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)) && (mSM.aSM.currentState != mSM.aSM.FallingState && mSM.aSM.currentState != mSM.aSM.WallRunState && mSM.aSM.currentState != mSM.aSM.WallIdleState) && !mSM.pStats.IsPaused){
mSM.SwitchState(mSM.SlideState);
}
}

View File

@ -22,7 +22,7 @@ public class dMoveRunState : dMoveBaseState
}
//move to slide if Q or JoystickButton1
else if((Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)) && (mSM.aSM.currentState != mSM.aSM.FallingState && mSM.aSM.currentState != mSM.aSM.WallRunState && mSM.aSM.currentState != mSM.aSM.WallIdleState && mSM.aSM.currentState != mSM.aSM.GrappleGroundedState) && !mSM.pStats.IsPaused){
else if((Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)) && (mSM.aSM.currentState != mSM.aSM.FallingState && mSM.aSM.currentState != mSM.aSM.WallRunState && mSM.aSM.currentState != mSM.aSM.WallIdleState) && !mSM.pStats.IsPaused){
mSM.SwitchState(mSM.SlideState);
}
}

View File

@ -29,7 +29,7 @@ public class dMoveWalkState : dMoveBaseState
}
//move to slide if Q or JoystickButton1
else if((Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)) && (mSM.aSM.currentState != mSM.aSM.FallingState && mSM.aSM.currentState != mSM.aSM.WallRunState && mSM.aSM.currentState != mSM.aSM.WallIdleState && mSM.aSM.currentState != mSM.aSM.GrappleGroundedState) && !mSM.pStats.IsPaused){
else if((Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)) && (mSM.aSM.currentState != mSM.aSM.FallingState && mSM.aSM.currentState != mSM.aSM.WallRunState && mSM.aSM.currentState != mSM.aSM.WallIdleState) && !mSM.pStats.IsPaused){
mSM.SwitchState(mSM.SlideState);
}
}

View File

@ -28,7 +28,7 @@ public class dOffenseAirKickState : dOffenseBaseState
public override void UpdateState(dOffenseStateManager oSM){
//if incapacitated then cooldown
if((oSM.mSM.currentState == oSM.mSM.RagdollState || oSM.mSM.currentState == oSM.mSM.SlideState || oSM.mSM.currentState == oSM.mSM.CrouchState || oSM.mSM.currentState == oSM.mSM.CrouchWalkState) || (oSM.aSM.currentState == oSM.aSM.WallRunState || oSM.aSM.currentState == oSM.aSM.WallIdleState || oSM.aSM.currentState == oSM.aSM.GrappleAirState || oSM.aSM.currentState == oSM.aSM.GrappleGroundedState)){
if((oSM.mSM.currentState == oSM.mSM.RagdollState || oSM.mSM.currentState == oSM.mSM.SlideState || oSM.mSM.currentState == oSM.mSM.CrouchState || oSM.mSM.currentState == oSM.mSM.CrouchWalkState) || (oSM.aSM.currentState == oSM.aSM.WallRunState || oSM.aSM.currentState == oSM.aSM.WallIdleState || oSM.aSM.currentState == oSM.aSM.GrappleAirState)){
oSM.SwitchState(oSM.CooldownState);
}

View File

@ -29,7 +29,7 @@ public class dOffenseKickState : dOffenseBaseState
public override void UpdateState(dOffenseStateManager oSM){
//if incapacitated then cooldown
if((oSM.mSM.currentState == oSM.mSM.RagdollState || oSM.mSM.currentState == oSM.mSM.SlideState || oSM.mSM.currentState == oSM.mSM.CrouchState || oSM.mSM.currentState == oSM.mSM.CrouchWalkState) || (oSM.aSM.currentState == oSM.aSM.WallRunState || oSM.aSM.currentState == oSM.aSM.WallIdleState || oSM.aSM.currentState == oSM.aSM.GrappleAirState || oSM.aSM.currentState == oSM.aSM.GrappleGroundedState)){
if((oSM.mSM.currentState == oSM.mSM.RagdollState || oSM.mSM.currentState == oSM.mSM.SlideState || oSM.mSM.currentState == oSM.mSM.CrouchState || oSM.mSM.currentState == oSM.mSM.CrouchWalkState) || (oSM.aSM.currentState == oSM.aSM.WallRunState || oSM.aSM.currentState == oSM.aSM.WallIdleState || oSM.aSM.currentState == oSM.aSM.GrappleAirState)){
oSM.SwitchState(oSM.CooldownState);
}

View File

@ -20,7 +20,7 @@ public class dOffenseCooldownState : dOffenseBaseState
public override void UpdateState(dOffenseStateManager oSM){
//if cooldown over and incapacitated then incapacitated
if(cooldown && (oSM.mSM.currentState == oSM.mSM.RagdollState || oSM.mSM.currentState == oSM.mSM.SlideState || oSM.mSM.currentState == oSM.mSM.CrouchState || oSM.mSM.currentState == oSM.mSM.CrouchWalkState) || (oSM.aSM.currentState == oSM.aSM.WallRunState || oSM.aSM.currentState == oSM.aSM.WallIdleState || oSM.aSM.currentState == oSM.aSM.GrappleAirState || oSM.aSM.currentState == oSM.aSM.GrappleGroundedState)){
if(cooldown && (oSM.mSM.currentState == oSM.mSM.RagdollState || oSM.mSM.currentState == oSM.mSM.SlideState || oSM.mSM.currentState == oSM.mSM.CrouchState || oSM.mSM.currentState == oSM.mSM.CrouchWalkState) || (oSM.aSM.currentState == oSM.aSM.WallRunState || oSM.aSM.currentState == oSM.aSM.WallIdleState || oSM.aSM.currentState == oSM.aSM.GrappleAirState)){
oSM.SwitchState(oSM.IncapacitatedState);
}

View File

@ -15,7 +15,7 @@ public class dOffenseIncapacitatedState : dOffenseBaseState
public override void UpdateState(dOffenseStateManager oSM){
//if no longer incapacitated then None
if((oSM.mSM.currentState != oSM.mSM.RagdollState && oSM.mSM.currentState != oSM.mSM.SlideState && oSM.mSM.currentState != oSM.mSM.CrouchState && oSM.mSM.currentState != oSM.mSM.CrouchWalkState) && (oSM.aSM.currentState != oSM.aSM.WallRunState && oSM.aSM.currentState != oSM.aSM.WallIdleState && oSM.aSM.currentState != oSM.aSM.GrappleAirState && oSM.aSM.currentState != oSM.aSM.GrappleGroundedState)){
if((oSM.mSM.currentState != oSM.mSM.RagdollState && oSM.mSM.currentState != oSM.mSM.SlideState && oSM.mSM.currentState != oSM.mSM.CrouchState && oSM.mSM.currentState != oSM.mSM.CrouchWalkState) && (oSM.aSM.currentState != oSM.aSM.WallRunState && oSM.aSM.currentState != oSM.aSM.WallIdleState && oSM.aSM.currentState != oSM.aSM.GrappleAirState)){
oSM.SwitchState(oSM.NoneState);
}
}

View File

@ -15,7 +15,7 @@ public class dOffenseNoneState : dOffenseBaseState
public override void UpdateState(dOffenseStateManager oSM){
//if incapacitated then incapacitated
if((oSM.mSM.currentState == oSM.mSM.RagdollState || oSM.mSM.currentState == oSM.mSM.SlideState || oSM.mSM.currentState == oSM.mSM.CrouchState || oSM.mSM.currentState == oSM.mSM.CrouchWalkState) || (oSM.aSM.currentState == oSM.aSM.WallRunState || oSM.aSM.currentState == oSM.aSM.WallIdleState || oSM.aSM.currentState == oSM.aSM.GrappleAirState || oSM.aSM.currentState == oSM.aSM.GrappleGroundedState)){
if((oSM.mSM.currentState == oSM.mSM.RagdollState || oSM.mSM.currentState == oSM.mSM.SlideState || oSM.mSM.currentState == oSM.mSM.CrouchState || oSM.mSM.currentState == oSM.mSM.CrouchWalkState) || (oSM.aSM.currentState == oSM.aSM.WallRunState || oSM.aSM.currentState == oSM.aSM.WallIdleState || oSM.aSM.currentState == oSM.aSM.GrappleAirState)){
oSM.SwitchState(oSM.IncapacitatedState);
}

View File

@ -24,11 +24,6 @@ public class AerialGroundedState : AerialBaseState
else if(aSM.pStats.GravVel > 0 && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.CrouchState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
aSM.SwitchState(aSM.JumpingState);
}
//can grapple and in state that allows grapple
else if(aSM.CheckGrapple() && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.CrouchState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
aSM.SwitchState(aSM.GrappleGroundedState);
}
}
public override void FixedUpdateState(AerialStateManager aSM){

View File

@ -24,7 +24,6 @@ public class AerialStateManager : NetworkBehaviour
public AerialWallIdleState WallIdleState = new AerialWallIdleState();
//Grappling States
public AerialGrappleGroundedState GrappleGroundedState = new AerialGrappleGroundedState();
public AerialGrappleAirState GrappleAirState = new AerialGrappleAirState();
////
@ -49,6 +48,7 @@ public class AerialStateManager : NetworkBehaviour
//Jump Variables
public int curJumpNum; // current Jumps Used
public bool jumpHeld; // Jump is Held
public bool canJump = true; // can the player jump
bool jumpPressed; // Jamp was pressed
public float coyJumpTimer = 0.1f; // Default Coyote Jump time
public float curCoyJumpTimer = 0.1f; // current Coyote Jump time
@ -88,21 +88,14 @@ public class AerialStateManager : NetworkBehaviour
Vector3 impact = Vector3.zero; // Impact Vector
//Grapple Variables
public float maxGrabDistance = 50;// Max Distance can cast grapple
float maxGrabDistance = 25;// Max Distance can cast grapple
public GameObject hookPoint; // Actual Hook points
public GameObject[] hookPoints; // Hook point list
public int hookPointIndex; // Hook point Index
public float distance; // distance of hookpoints
public float maxGrappleDistance = 25; // Max Rope Length
public float maxSwingSpeed = 50; // max swing speed
public float minSwingSpeed = 20; // min swing speed
public float swingAcc = 3f; // swing acceleration
public float maxSwingMom = 60; // max swing momentum
public bool release = false; // has player ungrappled
public Vector3 tempRelease; // temporary release force vector
public Vector3 lerpRelease; // lerped release force vector
public Vector3 forceDirection; // force direction vector
public bool eHeld; // is e being held
public Vector3 postForceDirection; // force direction vector
public float currentForcePower = 0;
////
void Awake(){
@ -282,15 +275,7 @@ public class AerialStateManager : NetworkBehaviour
//Actually applies the downwards movement
void DownwardMovement(){
Vector3 moveY = new Vector3(0,pStats.GravVel,0) * Time.deltaTime;
if(currentState == GrappleAirState){
moveY = (new Vector3(0,pStats.GravVel,0) + forceDirection) * Time.deltaTime;
}
moveController.Move(moveY);
moveController.Move(moveY);
}
//applies Jump values and Variables
@ -327,7 +312,7 @@ public class AerialStateManager : NetworkBehaviour
if(jumpHeld) curCoyJumpTimer = 0;
//If space/south face gamepad button isn't being pressed then jump is false
if (Input.GetAxis("Jump") == 0){
if (!Input.GetButton("Jump")){
jumpHeld = false;
}
@ -503,16 +488,16 @@ public class AerialStateManager : NetworkBehaviour
////
////Grapple Functions
//Checks if the player can grapple
public bool CheckGrapple(){
if(!pStats.IsPaused){
if ((Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.JoystickButton2)) && pStats.HasGrapple) //If grapple button is hit
{
Debug.Log("Checking Hooks");
hookPointIndex = FindHookPoint(); //Find the nearest hook point within max distance
if (hookPointIndex != -1) //If there is a hookpoint
{
Debug.Log("Found Hook");
hookPoint = hookPoints[hookPointIndex]; //The point we are grappling from
eHeld = true;
return true;
}
}
@ -539,9 +524,10 @@ public class AerialStateManager : NetworkBehaviour
//lerped grapple release force and dissipation of it
public void GrappleReleaseForce(){
if(release){
lerpRelease = Vector3.Lerp(lerpRelease, tempRelease, 9f * Time.deltaTime);
tempRelease *= .98f;
moveController.Move(lerpRelease);
currentForcePower *= .90f;
moveController.Move(postForceDirection * currentForcePower);
if(currentForcePower < .05) release = false;
}
}
////

View File

@ -5,263 +5,94 @@ using UnityEngine;
public class AerialGrappleAirState : AerialBaseState
{
bool spaceHeld = true;
float ropeLength; // current rope length
float inclinationAngle; // inclination angle
float theta = -1; // theta for rope angle
Vector3 hookPointRight; // right vector of the hook point
Vector3 curXZDir; // current straight line between player and hook point ignoring y axis
Vector3 oldXZDir; // old straight line between player and hook point ignoring y axis
Vector3 initialForceDirection;
Vector3 swingDirection; // Swing direction
float swingSpeed = 10; // cur swing speed
Vector3 tensionDirection; // tension direction
float tensionForce; // tension force amplifier
float swingMom; // swing Mom amplifier
float oldSwingMom; // old swing Momentum amplifier
Vector3 momDirection; // momentum direction
Vector3 tensionMomDirection; // tension momentum direction
float distanceBeneathHook = -3f;
float distanceAfterHook = 8f;
Vector3 desiredPosition;
bool pointReached = false;
float initialForcePower = 4;
float defaultGraceTimer = 1.0f; // default timer
float graceTimer; // grace period at the end of the swing so the player has time to let go
bool swingGrace = true; // is the grace timer over
public override void EnterState(AerialStateManager aSM, AerialBaseState previousState){
distanceBeneathHook = -3f;
distanceAfterHook = 8f;
pointReached = false;
initialForcePower = 4;
//refresh jump number
aSM.curJumpNum = 0;
aSM.release = false;
Vector3 updatedYHookPoint = new Vector3(aSM.hookPoint.transform.position.x, aSM.hookPoint.transform.position.y - distanceBeneathHook, aSM.hookPoint.transform.position.z);
Vector3 updatedXHookPointDirection = (new Vector3(aSM.transform.position.x, 0, aSM.transform.position.z) - new Vector3(aSM.hookPoint.transform.position.x, 0, aSM.hookPoint.transform.position.z)).normalized;
desiredPosition = updatedYHookPoint + (updatedXHookPointDirection * -distanceAfterHook);
//rope length limit
ropeLength = Vector3.Distance(aSM.transform.position, aSM.hookPoint.transform.position);
if(ropeLength > aSM.maxGrappleDistance){
ropeLength = aSM.maxGrappleDistance;
}
initialForceDirection = desiredPosition - aSM.transform.position;
initialForceDirection = initialForceDirection.normalized;
//old and cur direction vector for player to hookpoint
oldXZDir = (new Vector3(aSM.hookPoint.transform.position.x,0,aSM.hookPoint.transform.position.z) - new Vector3(aSM.transform.position.x,0,aSM.transform.position.z)).normalized;
curXZDir = (new Vector3(aSM.hookPoint.transform.position.x,0,aSM.hookPoint.transform.position.z) - new Vector3(aSM.transform.position.x,0,aSM.transform.position.z)).normalized;
aSM.postForceDirection = new Vector3(initialForceDirection.x, 0, initialForceDirection.z).normalized;
aSM.currentForcePower = initialForcePower;
//swing momentum calculation
swingMom = CalculateSwingMom(aSM.mSM.driftVel.magnitude * 50f, aSM);
oldSwingMom = swingMom;
//Initialize variables
aSM.pStats.GravVel = -1; // grav vel is adjusted so things work
aSM.release = false; // player hasn't released
aSM.lerpRelease = Vector3.zero; // reset lerp release
spaceHeld = true;
graceTimer = defaultGraceTimer; //sets grace timer
}
public override void ExitState(AerialStateManager aSM, AerialBaseState nextState){
//If not going into grapple grounded state
if(nextState != aSM.GrappleGroundedState){
aSM.release = true;
aSM.pStats.GravVel = 0;
aSM.forceDirection = Vector3.zero;
if(nextState == aSM.GroundedState || nextState == aSM.WallRunState){
aSM.release = false;
}
//If going into grapple grounded state
else{
aSM.pStats.GravVel = 0;
aSM.forceDirection = Vector3.zero;
aSM.release = true;
aSM.pStats.GravVel = 10;
}
}
public override void UpdateState(AerialStateManager aSM){
//if pressing E or ragdolling then falling
if(((Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.JoystickButton2)) && !aSM.eHeld && !aSM.pStats.IsPaused) || (aSM.mSM.currentState == aSM.mSM.RagdollState)){
aSM.SwitchState(aSM.FallingState);
if(pointReached){
//if grounded at when the point is reached then goto grounded state
if(aSM.isGrounded){
aSM.SwitchState(aSM.GroundedState);
}
else if(!aSM.isGrounded){
aSM.SwitchState(aSM.FallingState);
}
//if wallrunning then wallrun
else if(aSM.isWallRunning){
aSM.SwitchState(aSM.WallRunState);
}
}
else if((Input.GetKeyUp(KeyCode.E) || Input.GetKeyUp(KeyCode.JoystickButton2)) && aSM.eHeld){
aSM.eHeld = false;
}
//if pressing Jump then jump
else if(Input.GetButton("Jump") && !spaceHeld && !aSM.pStats.IsPaused){
aSM.SwitchState(aSM.JumpingState);
}
else if(!(Input.GetButton("Jump")) && spaceHeld){
spaceHeld = false;
}
//if grounded then grapple grounded
else if(aSM.isGrounded){
aSM.SwitchState(aSM.GrappleGroundedState);
}
//if wallrunning then wallrun
else if(aSM.isWallRunning){
aSM.SwitchState(aSM.WallRunState);
}
}
public override void FixedUpdateState(AerialStateManager aSM){
////////ADD A LINE RENDERER WHEN WE GET THE HAND MODEL
//Draw Line between player and hookpoint for debug purposes
Debug.DrawRay(aSM.transform.position, (aSM.hookPoint.transform.position - aSM.transform.position)); //Visual of line
Debug.DrawRay(aSM.transform.position, initialForceDirection); //Visual of line
//Calculate tether force direction based on hookpoint
if (Vector3.Distance(aSM.transform.position, aSM.hookPoint.transform.position) >= ropeLength )
{
aSM.forceDirection = CalculateForceDirection(1, aSM.pStats.GravVel, aSM.hookPoint.transform.position, aSM) + RopeLengthOffset(aSM.hookPoint.transform.position, Vector3.Distance(aSM.transform.position, aSM.hookPoint.transform.position), aSM);
Vector3 tempForceDir = desiredPosition - aSM.transform.position;
tempForceDir = tempForceDir.normalized;
tempForceDir = new Vector3(tempForceDir.x,0,tempForceDir.z).normalized;
if((aSM.postForceDirection - tempForceDir).magnitude >= .1f && !pointReached){
pointReached = true;
}
else{
aSM.forceDirection = Vector3.zero;
}
//Move player based on their inputs
aSM.moveController.Move(SwingMoveController(aSM));
//if Swing Momentum isn't zero then move player
if(swingMom != 0){
aSM.moveController.Move(CalculateMomentumDirection(aSM.pStats.GravVel, aSM.hookPoint.transform.position, aSM));
swingMom -= .5f;
}
if(swingMom<0) swingMom = 0;
//Calculate temp release at every position
aSM.tempRelease = CalculateSwingReleaseForce();
//Apply default gravity
aSM.GravityCalculation(aSM.pStats.PlayerGrav);
}
//Calculate the tether direction vector and how much force that vector needs
Vector3 CalculateForceDirection(float mass, float g, Vector3 hPoint, AerialStateManager aSM){
//tension direction and angle calculation
tensionDirection = (hPoint - aSM.transform.position).normalized;
inclinationAngle = Vector3.Angle((aSM.transform.position - hPoint).normalized, -aSM.transform.up);
theta = Mathf.Deg2Rad * inclinationAngle;
if(theta<=.1) theta = 0;
//How much force the tension needs
tensionForce = mass * -g * Mathf.Cos(theta);
//force direction calculation based on tension direction and force
Vector3 fDirection = tensionDirection * tensionForce;
//return force direction
return fDirection;
}
Vector3 CalculateMomentumDirection(float g, Vector3 hPoint, AerialStateManager aSM){
tensionMomDirection = (hPoint - aSM.transform.position).normalized;
hookPointRight = Vector3.Cross(oldXZDir, aSM.transform.up).normalized;
momDirection = -1 * Vector3.Cross(hookPointRight, tensionMomDirection).normalized;
//if player is on the other side of hookpoint and swingMom is lower then update oldXZDir
if(oldXZDir != curXZDir && swingMom <= (oldSwingMom*(.75f))){
if(graceTimer >= 0){
swingGrace = false;
graceTimer -= .1f;
}
else{
oldSwingMom = swingMom;
oldXZDir = (new Vector3(aSM.hookPoint.transform.position.x,0,aSM.hookPoint.transform.position.z) - new Vector3(aSM.transform.position.x,0,aSM.transform.position.z)).normalized;
swingGrace = true;
graceTimer = defaultGraceTimer;
}
if(!pointReached){
aSM.moveController.Move(initialForceDirection * initialForcePower);
aSM.GravityCalculation(0);
aSM.pStats.GravVel = 0;
}
else{
//currentForcePower;
aSM.GravityCalculation(aSM.pStats.PlayerGrav);
}
//current line between hookpoint and player
curXZDir = (new Vector3(hPoint.x,0,hPoint.z) - new Vector3(aSM.transform.position.x,0,aSM.transform.position.z)).normalized;
Debug.DrawRay(aSM.transform.position, momDirection * Time.deltaTime* 100, Color.green);
//return momentum dir * mom force
return (momDirection * Time.deltaTime * swingMom);
}
//Calculates the players initial swing momentum using their height and their current velocity
float CalculateSwingMom(float playerSpeed, AerialStateManager aSM){
//Calculate the players height compared to the lowest point in the swing
float swingHeight = aSM.transform.position.y - (aSM.hookPoint.transform.position.y - ropeLength);
if(swingHeight <= 1){
swingHeight = 1;
}
//calculates swing momentum based on height ands speed
float sMom = playerSpeed + (swingHeight * 2.5f);
if(sMom > aSM.maxSwingMom){
sMom = aSM.maxSwingMom;
}
//returns swing momentum
return sMom;
}
//Special movement for the player while they swing
Vector3 SwingMoveController(AerialStateManager aSM){
//WASD input
float inputVert = Input.GetAxis("Vertical");
float inputHor = Input.GetAxis("Horizontal");
//input is zero when nothing is pressed to prevent button easing values
if((!Input.GetKey(KeyCode.W) && !Input.GetKey(KeyCode.S))) inputVert = 0;
if((!Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.D))) inputHor = 0;
//Swingspeed build up
if((inputVert != 0 || inputHor != 0) && swingSpeed < aSM.maxSwingSpeed){
swingSpeed += aSM.swingAcc;
}
else if((inputVert != 0 || inputHor != 0) && swingSpeed >= aSM.maxSwingSpeed){
swingSpeed = aSM.maxSwingSpeed;
}
else if((inputVert == 0 && inputHor == 0)){
swingSpeed = aSM.minSwingSpeed;
}
//Swing direction based on player input
swingDirection = Vector3.Cross(tensionDirection, ((aSM.transform.right * -inputVert) + (aSM.transform.forward * inputHor))).normalized;
//Swing movement with swing speed added
Vector3 swingMovement = (swingDirection * Time.deltaTime * swingSpeed);
//returns swing movement vector
return (swingMovement);
}
Vector3 RopeLengthOffset(Vector3 hPoint, float curDistance, AerialStateManager aSM){
//How powerful our offset movement has to be
float offsetPower = ((curDistance - ropeLength) * 200f);
//The direction we need to apply force to offset when the rope gets lengthened beyond the necessary point
Vector3 tenDirOffset = (hPoint - aSM.transform.position).normalized;
//returns rope offset direction * power
return tenDirOffset * offsetPower * Time.deltaTime;
}
Vector3 CalculateSwingReleaseForce(){
//Swing release direction
Vector3 releaseSwingForceDirection = momDirection * ((swingMom) + 10);
releaseSwingForceDirection = new Vector3(releaseSwingForceDirection.x,0,releaseSwingForceDirection.z);
//if swingMom is low there is no release force
if(swingMom < 2){
return Vector3.zero;
}
//return swing release direction
return releaseSwingForceDirection * Time.deltaTime;
}
}

View File

@ -1,46 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AerialGrappleGroundedState : AerialBaseState
{
public override void EnterState(AerialStateManager aSM, AerialBaseState previousState){
aSM.release = false; // release is false when grounded
}
public override void ExitState(AerialStateManager aSM, AerialBaseState nextState){
}
public override void UpdateState(AerialStateManager aSM){
//if E is pressed or ragdolling then grounded
if(((Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.JoystickButton2)) && !aSM.eHeld && !aSM.pStats.IsPaused) || (aSM.mSM.currentState == aSM.mSM.RagdollState)){
aSM.SwitchState(aSM.GroundedState);
}
else if((Input.GetKeyUp(KeyCode.E) || Input.GetKeyUp(KeyCode.JoystickButton2)) && aSM.eHeld){
aSM.eHeld = false;
}
//if not grounded and gravVel < 0 then grapple air
else if(!aSM.isGrounded && aSM.pStats.GravVel < 0){
aSM.SwitchState(aSM.GrappleAirState);
}
//if distance between player and hookpoint is too far then grounded
else if(Vector3.Distance(aSM.transform.position, aSM.hookPoint.transform.position) > aSM.maxGrappleDistance){
aSM.SwitchState(aSM.GroundedState);
}
}
public override void FixedUpdateState(AerialStateManager aSM){
Debug.DrawRay(aSM.transform.position, (aSM.hookPoint.transform.position - aSM.transform.position)); //Visual of line
//Default gravity calculation
aSM.GravityCalculation(aSM.pStats.PlayerGrav);
}
}

View File

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

View File

@ -22,7 +22,7 @@ public class MoveIdleState : MoveBaseState
}
//If Q or joystick button1 crouch state
else if((Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)) && (mSM.aSM.currentState != mSM.aSM.FallingState && mSM.aSM.currentState != mSM.aSM.WallRunState && mSM.aSM.currentState != mSM.aSM.WallIdleState && mSM.aSM.currentState != mSM.aSM.GrappleGroundedState) && !mSM.pStats.IsPaused){
else if((Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)) && (mSM.aSM.currentState != mSM.aSM.FallingState && mSM.aSM.currentState != mSM.aSM.WallRunState && mSM.aSM.currentState != mSM.aSM.WallIdleState) && !mSM.pStats.IsPaused){
mSM.SwitchState(mSM.CrouchState);
}
}

View File

@ -26,7 +26,7 @@ public class MoveJogState : MoveBaseState
}
//move to slide if Q or JoystickButton1
else if((Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)) && (mSM.aSM.currentState != mSM.aSM.FallingState && mSM.aSM.currentState != mSM.aSM.WallRunState && mSM.aSM.currentState != mSM.aSM.WallIdleState && mSM.aSM.currentState != mSM.aSM.GrappleGroundedState) && !mSM.pStats.IsPaused){
else if((Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)) && (mSM.aSM.currentState != mSM.aSM.FallingState && mSM.aSM.currentState != mSM.aSM.WallRunState && mSM.aSM.currentState != mSM.aSM.WallIdleState) && !mSM.pStats.IsPaused){
mSM.SwitchState(mSM.SlideState);
}
}

View File

@ -22,7 +22,7 @@ public class MoveRunState : MoveBaseState
}
//move to slide if Q or JoystickButton1
else if((Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)) && (mSM.aSM.currentState != mSM.aSM.FallingState && mSM.aSM.currentState != mSM.aSM.WallRunState && mSM.aSM.currentState != mSM.aSM.WallIdleState && mSM.aSM.currentState != mSM.aSM.GrappleGroundedState) && !mSM.pStats.IsPaused){
else if((Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)) && (mSM.aSM.currentState != mSM.aSM.FallingState && mSM.aSM.currentState != mSM.aSM.WallRunState && mSM.aSM.currentState != mSM.aSM.WallIdleState) && !mSM.pStats.IsPaused){
mSM.SwitchState(mSM.SlideState);
}
}

View File

@ -26,7 +26,7 @@ public class MoveWalkState : MoveBaseState
}
//move to slide if Q or JoystickButton1
else if((Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)) && (mSM.aSM.currentState != mSM.aSM.FallingState && mSM.aSM.currentState != mSM.aSM.WallRunState && mSM.aSM.currentState != mSM.aSM.WallIdleState && mSM.aSM.currentState != mSM.aSM.GrappleGroundedState) && !mSM.pStats.IsPaused){
else if((Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)) && (mSM.aSM.currentState != mSM.aSM.FallingState && mSM.aSM.currentState != mSM.aSM.WallRunState && mSM.aSM.currentState != mSM.aSM.WallIdleState) && !mSM.pStats.IsPaused){
mSM.SwitchState(mSM.SlideState);
}
}

View File

@ -28,7 +28,7 @@ public class OffenseAirKickState : OffenseBaseState
public override void UpdateState(OffenseStateManager oSM){
//if incapacitated then cooldown
if((oSM.mSM.currentState == oSM.mSM.RagdollState || oSM.mSM.currentState == oSM.mSM.SlideState || oSM.mSM.currentState == oSM.mSM.CrouchState || oSM.mSM.currentState == oSM.mSM.CrouchWalkState) || (oSM.aSM.currentState == oSM.aSM.WallRunState || oSM.aSM.currentState == oSM.aSM.WallIdleState || oSM.aSM.currentState == oSM.aSM.GrappleAirState || oSM.aSM.currentState == oSM.aSM.GrappleGroundedState)){
if((oSM.mSM.currentState == oSM.mSM.RagdollState || oSM.mSM.currentState == oSM.mSM.SlideState || oSM.mSM.currentState == oSM.mSM.CrouchState || oSM.mSM.currentState == oSM.mSM.CrouchWalkState) || (oSM.aSM.currentState == oSM.aSM.WallRunState || oSM.aSM.currentState == oSM.aSM.WallIdleState || oSM.aSM.currentState == oSM.aSM.GrappleAirState)){
oSM.SwitchState(oSM.CooldownState);
}

View File

@ -28,7 +28,7 @@ public class OffenseKickState : OffenseBaseState
public override void UpdateState(OffenseStateManager oSM){
//if incapacitated then cooldown
if((oSM.mSM.currentState == oSM.mSM.RagdollState || oSM.mSM.currentState == oSM.mSM.SlideState || oSM.mSM.currentState == oSM.mSM.CrouchState || oSM.mSM.currentState == oSM.mSM.CrouchWalkState) || (oSM.aSM.currentState == oSM.aSM.WallRunState || oSM.aSM.currentState == oSM.aSM.WallIdleState || oSM.aSM.currentState == oSM.aSM.GrappleAirState || oSM.aSM.currentState == oSM.aSM.GrappleGroundedState)){
if((oSM.mSM.currentState == oSM.mSM.RagdollState || oSM.mSM.currentState == oSM.mSM.SlideState || oSM.mSM.currentState == oSM.mSM.CrouchState || oSM.mSM.currentState == oSM.mSM.CrouchWalkState) || (oSM.aSM.currentState == oSM.aSM.WallRunState || oSM.aSM.currentState == oSM.aSM.WallIdleState || oSM.aSM.currentState == oSM.aSM.GrappleAirState)){
oSM.SwitchState(oSM.CooldownState);
}

View File

@ -19,7 +19,7 @@ public class OffenseCooldownState : OffenseBaseState
public override void UpdateState(OffenseStateManager oSM){
//if cooldown over and incapacitated then incapacitated
if(cooldown && (oSM.mSM.currentState == oSM.mSM.RagdollState || oSM.mSM.currentState == oSM.mSM.SlideState || oSM.mSM.currentState == oSM.mSM.CrouchState || oSM.mSM.currentState == oSM.mSM.CrouchWalkState) || (oSM.aSM.currentState == oSM.aSM.WallRunState || oSM.aSM.currentState == oSM.aSM.WallIdleState || oSM.aSM.currentState == oSM.aSM.GrappleAirState || oSM.aSM.currentState == oSM.aSM.GrappleGroundedState)){
if(cooldown && (oSM.mSM.currentState == oSM.mSM.RagdollState || oSM.mSM.currentState == oSM.mSM.SlideState || oSM.mSM.currentState == oSM.mSM.CrouchState || oSM.mSM.currentState == oSM.mSM.CrouchWalkState) || (oSM.aSM.currentState == oSM.aSM.WallRunState || oSM.aSM.currentState == oSM.aSM.WallIdleState || oSM.aSM.currentState == oSM.aSM.GrappleAirState)){
oSM.SwitchState(oSM.IncapacitatedState);
}

View File

@ -15,7 +15,7 @@ public class OffenseIncapacitatedState : OffenseBaseState
public override void UpdateState(OffenseStateManager oSM){
//if no longer incapacitated then None
if((oSM.mSM.currentState != oSM.mSM.RagdollState && oSM.mSM.currentState != oSM.mSM.SlideState && oSM.mSM.currentState != oSM.mSM.CrouchState && oSM.mSM.currentState != oSM.mSM.CrouchWalkState) && (oSM.aSM.currentState != oSM.aSM.WallRunState && oSM.aSM.currentState != oSM.aSM.WallIdleState && oSM.aSM.currentState != oSM.aSM.GrappleAirState && oSM.aSM.currentState != oSM.aSM.GrappleGroundedState)){
if((oSM.mSM.currentState != oSM.mSM.RagdollState && oSM.mSM.currentState != oSM.mSM.SlideState && oSM.mSM.currentState != oSM.mSM.CrouchState && oSM.mSM.currentState != oSM.mSM.CrouchWalkState) && (oSM.aSM.currentState != oSM.aSM.WallRunState && oSM.aSM.currentState != oSM.aSM.WallIdleState && oSM.aSM.currentState != oSM.aSM.GrappleAirState)){
oSM.SwitchState(oSM.NoneState);
}
}

View File

@ -15,7 +15,7 @@ public class OffenseNoneState : OffenseBaseState
public override void UpdateState(OffenseStateManager oSM){
//if incapacitated then incapacitated
if((oSM.mSM.currentState == oSM.mSM.RagdollState || oSM.mSM.currentState == oSM.mSM.SlideState || oSM.mSM.currentState == oSM.mSM.CrouchState || oSM.mSM.currentState == oSM.mSM.CrouchWalkState) || (oSM.aSM.currentState == oSM.aSM.WallRunState || oSM.aSM.currentState == oSM.aSM.WallIdleState || oSM.aSM.currentState == oSM.aSM.GrappleAirState || oSM.aSM.currentState == oSM.aSM.GrappleGroundedState)){
if((oSM.mSM.currentState == oSM.mSM.RagdollState || oSM.mSM.currentState == oSM.mSM.SlideState || oSM.mSM.currentState == oSM.mSM.CrouchState || oSM.mSM.currentState == oSM.mSM.CrouchWalkState) || (oSM.aSM.currentState == oSM.aSM.WallRunState || oSM.aSM.currentState == oSM.aSM.WallIdleState || oSM.aSM.currentState == oSM.aSM.GrappleAirState)){
oSM.SwitchState(oSM.IncapacitatedState);
}

View File

@ -12,7 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 220c578e08133f54a95a442eb87b3702, type: 3}
m_Name: Dash
m_EditorClassIdentifier:
id: 11
id: 1
itemName: Dash
description: (Active) Press R to quickly dash your player forward.
itemSprite: {fileID: 2061666376165797104, guid: 6752962b9a0f4984fa08cb5a13e7bdfa, type: 3}

View File

@ -12,7 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 220c578e08133f54a95a442eb87b3702, type: 3}
m_Name: Glider
m_EditorClassIdentifier:
id: 7
id: 2
itemName: Glider
description: (Active) Hold space while falling to slow your descent.
itemSprite: {fileID: 4561481026067350109, guid: 6752962b9a0f4984fa08cb5a13e7bdfa, type: 3}

View File

@ -12,7 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 220c578e08133f54a95a442eb87b3702, type: 3}
m_Name: Grapple
m_EditorClassIdentifier:
id: 8
id: 3
itemName: Grapple
description: (Active) Press E to grapple to a nearby grapple point.
itemSprite: {fileID: 4914967321489272866, guid: 6752962b9a0f4984fa08cb5a13e7bdfa, type: 3}

View File

@ -12,7 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 220c578e08133f54a95a442eb87b3702, type: 3}
m_Name: Nitro
m_EditorClassIdentifier:
id: 10
id: 4
itemName: Nitro
description: (Active) Press Left Shift to boost your player speed beyond its max
for a short period.

View File

@ -12,7 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d76cac0a7f5ea2a4cadbec8ef3315ec1, type: 3}
m_Name: RollerSkates
m_EditorClassIdentifier:
id: 2
id: 5
itemName: Roller Skates
description: (Passive) Increases your max speed and acceleration at the cost of
traction.

View File

@ -12,7 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d76cac0a7f5ea2a4cadbec8ef3315ec1, type: 3}
m_Name: Springs
m_EditorClassIdentifier:
id: 3
id: 6
itemName: Springs
description: (Passive) Your jumps will be more powerful.
itemSprite: {fileID: 7727917336835008987, guid: 6752962b9a0f4984fa08cb5a13e7bdfa, type: 3}

View File

@ -12,7 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d76cac0a7f5ea2a4cadbec8ef3315ec1, type: 3}
m_Name: TripleJump
m_EditorClassIdentifier:
id: 5
id: 7
itemName: Triple Jump
description: (Passive) Your jump height will be reduced slightly but you will gain
an extra jump.

View File

@ -12,7 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 220c578e08133f54a95a442eb87b3702, type: 3}
m_Name: Wall Run
m_EditorClassIdentifier:
id: 6
id: 8
itemName: Wall Run
description: (Passive) You now have the ability to run across red walls.
itemSprite: {fileID: 4715863182911615046, guid: 6752962b9a0f4984fa08cb5a13e7bdfa, type: 3}

View File

@ -27,10 +27,10 @@ EditorUserSettings:
value: 22424703114646680e0b0227036c731f1415016439262f2434
flags: 0
RecentlyUsedScenePath-7:
value: 22424703114646680e0b0227036c78111b125507233d28242c20137df7ee3d2cfb
value: 22424703114646680e0b0227036c7b151b180b6519016b0515163936efef2776f7e93ffdfe
flags: 0
RecentlyUsedScenePath-8:
value: 22424703114646680e0b0227036c6f02131b172b282d347e38271427fb
value: 22424703114646680e0b0227036c731f1415016439262f2434
flags: 0
RecentlyUsedScenePath-9:
value: 22424703114646680e0b0227036c78111b125507233d28242c20137df7ee3d2cfb