mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-08-21 18:04:27 -05:00
Added body parts to networked player
This commit is contained in:
@@ -30,6 +30,11 @@ public class AerialStateManager : NetworkBehaviour
|
||||
////Objects Sections
|
||||
GameObject parentObj; // Parent object
|
||||
public Camera cam;
|
||||
public GameObject stickyHandParent;
|
||||
public LineRenderer lr;
|
||||
public CharacterController handController;
|
||||
public Transform handPosition;
|
||||
public GameObject removeableHand;
|
||||
////
|
||||
|
||||
////Components Section
|
||||
@@ -310,56 +315,56 @@ public class AerialStateManager : 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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
mSM.CancelMomentum();
|
||||
}
|
||||
|
||||
@@ -7,19 +7,22 @@ public class AerialGrappleAirState : AerialBaseState
|
||||
|
||||
Vector3 initialForceDirection;
|
||||
|
||||
float distanceBeneathHook = -3f;
|
||||
float distanceAfterHook = 8f;
|
||||
float distanceBeneathHook;
|
||||
float distanceAfterHook;
|
||||
Vector3 desiredPosition;
|
||||
Vector3 playerOffset;
|
||||
Vector3 lastPos;
|
||||
|
||||
bool pointReached = false;
|
||||
bool pointReached;
|
||||
bool handReached = false;
|
||||
|
||||
float initialForcePower = 100;
|
||||
float initialForcePower;
|
||||
|
||||
|
||||
public override void EnterState(AerialStateManager aSM, AerialBaseState previousState){
|
||||
|
||||
|
||||
distanceBeneathHook = -3f;
|
||||
distanceBeneathHook = -2f;
|
||||
distanceAfterHook = 8f;
|
||||
pointReached = false;
|
||||
initialForcePower = 100;
|
||||
@@ -39,9 +42,18 @@ public class AerialGrappleAirState : AerialBaseState
|
||||
aSM.postForceDirection = new Vector3(initialForceDirection.x, 0, initialForceDirection.z).normalized;
|
||||
aSM.currentForcePower = initialForcePower;
|
||||
|
||||
lastPos = aSM.transform.position;
|
||||
handReached = false;
|
||||
|
||||
}
|
||||
|
||||
public override void ExitState(AerialStateManager aSM, AerialBaseState nextState){
|
||||
aSM.stickyHandParent.transform.localEulerAngles = Vector3.zero;
|
||||
aSM.handController.enabled = false;
|
||||
aSM.stickyHandParent.SetActive(false);
|
||||
aSM.lr.enabled = false;
|
||||
aSM.removeableHand.SetActive(true);
|
||||
|
||||
if(nextState == aSM.GroundedState || nextState == aSM.WallRunState){
|
||||
aSM.release = false;
|
||||
}
|
||||
@@ -65,10 +77,14 @@ public class AerialGrappleAirState : AerialBaseState
|
||||
aSM.SwitchState(aSM.WallRunState);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(AerialStateManager 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 +98,12 @@ public class AerialGrappleAirState : AerialBaseState
|
||||
}
|
||||
|
||||
//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 +112,44 @@ public class AerialGrappleAirState : AerialBaseState
|
||||
//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(AerialStateManager aSM){
|
||||
if(!aSM.stickyHandParent.active){
|
||||
aSM.removeableHand.SetActive(false);
|
||||
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(AerialStateManager 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);
|
||||
}
|
||||
else{
|
||||
aSM.removeableHand.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user