diff --git a/Assets/Scenes/Demos/MovementScene.unity b/Assets/Scenes/Demos/MovementScene.unity index 4131b79..e6a859e 100644 --- a/Assets/Scenes/Demos/MovementScene.unity +++ b/Assets/Scenes/Demos/MovementScene.unity @@ -1600,6 +1600,10 @@ PrefabInstance: propertyPath: m_Name value: DebugPlayerPrefab 1 objectReference: {fileID: 0} + - target: {fileID: 6664667533527261801, guid: 6adb8bcc65ee3a54da64d7c65225f219, type: 3} + propertyPath: hasGrapple + value: 1 + objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 6adb8bcc65ee3a54da64d7c65225f219, type: 3} --- !u!1 &1493944130 diff --git a/Assets/Scripts/PlayerScripts/DebugPlayer/DebugItems/dGrapplingHook.cs b/Assets/Scripts/PlayerScripts/DebugPlayer/DebugItems/dGrapplingHook.cs index c49bb2a..a8609c0 100644 --- a/Assets/Scripts/PlayerScripts/DebugPlayer/DebugItems/dGrapplingHook.cs +++ b/Assets/Scripts/PlayerScripts/DebugPlayer/DebugItems/dGrapplingHook.cs @@ -64,7 +64,7 @@ public class dGrapplingHook : NetworkBehaviour if (hookPointIndex != -1) //If there is a hookpoint { hookPoint = hookPoints[hookPointIndex]; //The point we are grappling from - ropeLength = Vector3.Distance(gameObject.transform.position, hookPoint.transform.position) + 0.5f; + ropeLength = Vector3.Distance(gameObject.transform.position, hookPoint.transform.position); oldXZDir = (new Vector3(hookPoint.transform.position.x,0,hookPoint.transform.position.z) - new Vector3(transform.position.x,0,transform.position.z)).normalized; curXZDir = (new Vector3(hookPoint.transform.position.x,0,hookPoint.transform.position.z) - new Vector3(transform.position.x,0,transform.position.z)).normalized; isGrappled = true; //toggle grappling state @@ -73,6 +73,7 @@ public class dGrapplingHook : NetworkBehaviour else //Else we are grappling { isGrappled = false; //toggle grappling state to release + playerMovement.g = 0; } } } @@ -108,12 +109,16 @@ public class dGrapplingHook : NetworkBehaviour //Debug.Log(Vector3.Distance(gameObject.transform.position, hookPoint.transform.position)); Debug.Log(ropeLength); //Calculate tether force direction based on hookpoint - if (Vector3.Distance(gameObject.transform.position, hookPoint.transform.position) >= ropeLength ) + if (Vector3.Distance(gameObject.transform.position, hookPoint.transform.position) > ropeLength ) { - forceDirection = calculateForceDirection(1, playerMovement.g+.01f, hookPoint.transform.position); + forceDirection = calculateForceDirection(1, playerMovement.g+.01f, hookPoint.transform.position) + ropeLengthOffset(hookPoint.transform.position, Vector3.Distance(gameObject.transform.position, hookPoint.transform.position)); + } + else{ + forceDirection = Vector3.zero; + } //apply special swing movement when aerial if(!playerMovement.isGrounded){ @@ -209,6 +214,7 @@ public class dGrapplingHook : NetworkBehaviour //Swing direction based on player input swingDirection = Vector3.Cross(tensionDirection, ((transform.right * -inputVert) + (transform.forward * inputHor))).normalized; + //NEED TO ADD SWINGSPEED EASING //Swing movement with swing speed added Vector3 swingMovement = (swingDirection * Time.deltaTime * maxSwingSpeed); @@ -216,4 +222,16 @@ public class dGrapplingHook : NetworkBehaviour return (swingMovement); } + + Vector3 ropeLengthOffset(Vector3 hPoint, float curDistance){ + + //How powerful our offset movement has to be + float offsetPower = ((curDistance - ropeLength) * 10f); + + //The direction we need to apply force to offset when the rope gets lengthened beyond the necessary point + Vector3 tenDirOffset = (hPoint - transform.position).normalized; + + + return tenDirOffset * offsetPower; + } }