mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-08-21 09:54:28 -05:00
Added body parts to networked player
This commit is contained in:
@@ -26,12 +26,12 @@ public class dAerialJumpingState : dAerialBaseState
|
||||
}
|
||||
|
||||
//if is wall running and in a state that allows it wallrun
|
||||
else if(aSM.isWallRunning){
|
||||
else if(aSM.isWallRunning && (aSM.isWallRunning && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.CrouchState && aSM.mSM.currentState != aSM.mSM.CrouchWalkState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState))){
|
||||
aSM.SwitchState(aSM.WallRunState);
|
||||
}
|
||||
|
||||
//if can grapple and in a state that allows it grapple
|
||||
else if(aSM.CheckGrapple()){
|
||||
else if(aSM.CheckGrapple() && (aSM.CheckGrapple() && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.CrouchState && aSM.mSM.currentState != aSM.mSM.CrouchWalkState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState))){
|
||||
aSM.SwitchState(aSM.GrappleAirState);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,11 @@ public class dAerialGrappleAirState : dAerialBaseState
|
||||
float distanceBeneathHook;
|
||||
float distanceAfterHook;
|
||||
Vector3 desiredPosition;
|
||||
Vector3 playerOffset;
|
||||
Vector3 lastPos;
|
||||
|
||||
bool pointReached;
|
||||
bool handReached = false;
|
||||
|
||||
float initialForcePower;
|
||||
|
||||
@@ -19,10 +22,10 @@ public class dAerialGrappleAirState : dAerialBaseState
|
||||
public override void EnterState(dAerialStateManager aSM, dAerialBaseState previousState){
|
||||
|
||||
|
||||
distanceBeneathHook = -3f;
|
||||
distanceBeneathHook = -2f;
|
||||
distanceAfterHook = 8f;
|
||||
pointReached = false;
|
||||
initialForcePower = 80;
|
||||
initialForcePower = 100;
|
||||
|
||||
//refresh jump number
|
||||
aSM.curJumpNum = 0;
|
||||
@@ -39,9 +42,17 @@ public class dAerialGrappleAirState : dAerialBaseState
|
||||
aSM.postForceDirection = new Vector3(initialForceDirection.x, 0, initialForceDirection.z).normalized;
|
||||
aSM.currentForcePower = initialForcePower;
|
||||
|
||||
lastPos = aSM.transform.position;
|
||||
handReached = false;
|
||||
|
||||
}
|
||||
|
||||
public override void ExitState(dAerialStateManager aSM, dAerialBaseState nextState){
|
||||
aSM.stickyHandParent.transform.localEulerAngles = Vector3.zero;
|
||||
aSM.handController.enabled = false;
|
||||
aSM.stickyHandParent.SetActive(false);
|
||||
aSM.lr.enabled = false;
|
||||
|
||||
if(nextState == aSM.GroundedState || nextState == aSM.WallRunState){
|
||||
aSM.release = false;
|
||||
}
|
||||
@@ -65,10 +76,14 @@ public class dAerialGrappleAirState : dAerialBaseState
|
||||
aSM.SwitchState(aSM.WallRunState);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(dAerialStateManager aSM){
|
||||
|
||||
playerOffset = aSM.transform.position - lastPos;
|
||||
lastPos = aSM.transform.position;
|
||||
|
||||
////////ADD A LINE RENDERER WHEN WE GET THE HAND MODEL
|
||||
//Draw Line between player and hookpoint for debug purposes
|
||||
Debug.DrawRay(aSM.transform.position, initialForceDirection); //Visual of line
|
||||
@@ -82,7 +97,12 @@ public class dAerialGrappleAirState : dAerialBaseState
|
||||
}
|
||||
|
||||
//Apply default gravity
|
||||
if(!pointReached){
|
||||
if(!handReached){
|
||||
ThrowStickyHand(aSM);
|
||||
aSM.GravityCalculation(aSM.pStats.PlayerGrav);
|
||||
}
|
||||
else if(!pointReached && handReached){
|
||||
RetrieveStickyHand(aSM);
|
||||
aSM.moveController.Move(initialForceDirection * initialForcePower * Time.deltaTime);
|
||||
aSM.GravityCalculation(0);
|
||||
aSM.pStats.GravVel = 0;
|
||||
@@ -91,6 +111,40 @@ public class dAerialGrappleAirState : dAerialBaseState
|
||||
//currentForcePower;
|
||||
aSM.GravityCalculation(aSM.pStats.PlayerGrav);
|
||||
}
|
||||
|
||||
if(aSM.stickyHandParent.active){
|
||||
aSM.stickyHandParent.transform.localRotation = Quaternion.Euler(0.0f, 0.0f, aSM.stickyHandParent.transform.parent.rotation.z * -1.0f);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void ThrowStickyHand(dAerialStateManager aSM){
|
||||
if(!aSM.stickyHandParent.active){
|
||||
aSM.stickyHandParent.SetActive(true);
|
||||
aSM.lr.enabled = true;
|
||||
aSM.stickyHandParent.transform.position = aSM.handPosition.position;
|
||||
aSM.handController.enabled = true;
|
||||
}
|
||||
|
||||
aSM.lr.SetPosition(0,aSM.stickyHandParent.transform.position);
|
||||
aSM.lr.SetPosition(1,aSM.handPosition.transform.position);
|
||||
|
||||
Vector3 throwDir = (aSM.hookPoint.transform.position - aSM.stickyHandParent.transform.position).normalized;
|
||||
|
||||
aSM.stickyHandParent.GetComponent<CharacterController>().Move(throwDir * 80 * Time.deltaTime);
|
||||
if(Vector3.Distance(aSM.hookPoint.transform.position, aSM.stickyHandParent.transform.position) <= 3f){
|
||||
handReached = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void RetrieveStickyHand(dAerialStateManager aSM){
|
||||
aSM.lr.SetPosition(0,aSM.stickyHandParent.transform.position);
|
||||
aSM.lr.SetPosition(1,aSM.handPosition.transform.position);
|
||||
|
||||
Vector3 catchDir = (aSM.handPosition.transform.position - aSM.stickyHandParent.transform.position).normalized;
|
||||
if(Vector3.Distance(aSM.handPosition.transform.position, aSM.stickyHandParent.transform.position) > .5f){
|
||||
aSM.stickyHandParent.GetComponent<CharacterController>().Move(catchDir * 30 * Time.deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -28,6 +28,10 @@ public class dAerialStateManager : NetworkBehaviour
|
||||
////Objects Sections
|
||||
GameObject parentObj; // Parent object
|
||||
public Camera cam;
|
||||
public GameObject stickyHandParent;
|
||||
public LineRenderer lr;
|
||||
public CharacterController handController;
|
||||
public Transform handPosition;
|
||||
////
|
||||
|
||||
////Components Section
|
||||
@@ -58,7 +62,7 @@ public class dAerialStateManager : NetworkBehaviour
|
||||
//Ground Check
|
||||
public bool isGrounded; // is player grounded
|
||||
public float groundCheckDistance = 0.05f; // offset distance to check ground
|
||||
private float groundSlantDistance = .3f;
|
||||
private float groundSlantDistance = .2f;
|
||||
const float jumpGroundingPreventionTime = 0.2f; // delay so player doesn't get snapped to ground while jumping
|
||||
const float groundCheckDistanceInAir = 0.07f; // How close we have to get to ground to start checking for grounded again
|
||||
Vector3 raycastOffset;
|
||||
@@ -282,56 +286,65 @@ public class dAerialStateManager : NetworkBehaviour
|
||||
}
|
||||
else if(currentState != WallRunState){
|
||||
if(Physics.Raycast(groundRay, out groundHit, moveController.height + groundSlantDistance) && !jumpPressed && curCoyJumpTimer <= 0){
|
||||
if(Vector3.Dot(groundHit.normal, transform.up) <= .8f){
|
||||
if(Vector3.Dot(groundHit.normal, transform.up) <= .8f && Vector3.Dot(groundHit.normal, transform.up) > 0f ){
|
||||
moveController.Move(groundHit.normal * 20 * Time.deltaTime);
|
||||
Debug.Log(Vector3.Dot(groundHit.normal, transform.up) );
|
||||
mSM.CancelMomentum();
|
||||
}
|
||||
}
|
||||
else if(Physics.Raycast(angleRayLeft, out groundHit, moveController.height + groundSlantDistance) && !jumpPressed && curCoyJumpTimer <= 0){
|
||||
if(Vector3.Dot(groundHit.normal, transform.up) <= .8f){
|
||||
if(Vector3.Dot(groundHit.normal, transform.up) <= .8f && Vector3.Dot(groundHit.normal, transform.up) > 0f ){
|
||||
moveController.Move(groundHit.normal * 20 * Time.deltaTime);
|
||||
Debug.Log(Vector3.Dot(groundHit.normal, transform.up) );
|
||||
mSM.CancelMomentum();
|
||||
}
|
||||
}
|
||||
else if(Physics.Raycast(angleRayRight, out groundHit, moveController.height + groundSlantDistance) && !jumpPressed && curCoyJumpTimer <= 0){
|
||||
if(Vector3.Dot(groundHit.normal, transform.up) <= .8f){
|
||||
if(Vector3.Dot(groundHit.normal, transform.up) <= .8f && Vector3.Dot(groundHit.normal, transform.up) > 0f ){
|
||||
moveController.Move(groundHit.normal * 20 * Time.deltaTime);
|
||||
Debug.Log(Vector3.Dot(groundHit.normal, transform.up) );
|
||||
mSM.CancelMomentum();
|
||||
}
|
||||
}
|
||||
else if(Physics.Raycast(angleRayForward, out groundHit, moveController.height + groundSlantDistance) && !jumpPressed && curCoyJumpTimer <= 0){
|
||||
if(Vector3.Dot(groundHit.normal, transform.up) <= .8f){
|
||||
if(Vector3.Dot(groundHit.normal, transform.up) <= .8f && Vector3.Dot(groundHit.normal, transform.up) > 0f ){
|
||||
moveController.Move(groundHit.normal * 20 * Time.deltaTime);
|
||||
Debug.Log(Vector3.Dot(groundHit.normal, transform.up) );
|
||||
mSM.CancelMomentum();
|
||||
}
|
||||
}
|
||||
else if(Physics.Raycast(angleRayBackwards, out groundHit, moveController.height + groundSlantDistance) && !jumpPressed && curCoyJumpTimer <= 0){
|
||||
if(Vector3.Dot(groundHit.normal, transform.up) <= .8f){
|
||||
if(Vector3.Dot(groundHit.normal, transform.up) <= .8f && Vector3.Dot(groundHit.normal, transform.up) > 0f ){
|
||||
moveController.Move(groundHit.normal * 20 * Time.deltaTime);
|
||||
Debug.Log(Vector3.Dot(groundHit.normal, transform.up) );
|
||||
mSM.CancelMomentum();
|
||||
}
|
||||
}
|
||||
else if(Physics.Raycast(angleRayLeftR, out groundHit, moveController.height + groundSlantDistance) && !jumpPressed && curCoyJumpTimer <= 0){
|
||||
if(Vector3.Dot(groundHit.normal, transform.up) <= .8f){
|
||||
if(Vector3.Dot(groundHit.normal, transform.up) <= .8f && Vector3.Dot(groundHit.normal, transform.up) > 0f ){
|
||||
moveController.Move(groundHit.normal * 20 * Time.deltaTime);
|
||||
Debug.Log(Vector3.Dot(groundHit.normal, transform.up) );
|
||||
mSM.CancelMomentum();
|
||||
}
|
||||
}
|
||||
else if(Physics.Raycast(angleRayRightL, out groundHit, moveController.height + groundSlantDistance) && !jumpPressed && curCoyJumpTimer <= 0){
|
||||
if(Vector3.Dot(groundHit.normal, transform.up) <= .8f){
|
||||
if(Vector3.Dot(groundHit.normal, transform.up) <= .8f && Vector3.Dot(groundHit.normal, transform.up) > 0f ){
|
||||
moveController.Move(groundHit.normal * 20 * Time.deltaTime);
|
||||
Debug.Log(Vector3.Dot(groundHit.normal, transform.up) );
|
||||
mSM.CancelMomentum();
|
||||
}
|
||||
}
|
||||
else if(Physics.Raycast(angleRayForwardB, out groundHit, moveController.height + groundSlantDistance) && !jumpPressed && curCoyJumpTimer <= 0){
|
||||
if(Vector3.Dot(groundHit.normal, transform.up) <= .8f){
|
||||
if(Vector3.Dot(groundHit.normal, transform.up) <= .8f && Vector3.Dot(groundHit.normal, transform.up) > 0f ){
|
||||
moveController.Move(groundHit.normal * 20 * Time.deltaTime);
|
||||
Debug.Log(Vector3.Dot(groundHit.normal, transform.up) );
|
||||
mSM.CancelMomentum();
|
||||
}
|
||||
}
|
||||
else if(Physics.Raycast(angleRayBackwardsF, out groundHit, moveController.height + groundSlantDistance) && !jumpPressed && curCoyJumpTimer <= 0){
|
||||
if(Vector3.Dot(groundHit.normal, transform.up) <= .8f){
|
||||
if(Vector3.Dot(groundHit.normal, transform.up) <= .8f && Vector3.Dot(groundHit.normal, transform.up) > 0f ){
|
||||
moveController.Move(groundHit.normal * 20 * Time.deltaTime);
|
||||
Debug.Log(Vector3.Dot(groundHit.normal, transform.up) );
|
||||
mSM.CancelMomentum();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user