mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-04-25 07:57:08 -05:00
idle grapple calculations have been solidified
I can now move into adding how player speed and height effect these things
This commit is contained in:
parent
93d2ce9c40
commit
e249e5d4d5
|
|
@ -1781,7 +1781,7 @@ RectTransform:
|
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: -352, y: 424}
|
||||
m_AnchoredPosition: {x: -352, y: 441}
|
||||
m_SizeDelta: {x: 100, y: 100}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &2362000826974438061
|
||||
|
|
@ -2008,8 +2008,8 @@ RectTransform:
|
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: -2.8183, y: 0}
|
||||
m_SizeDelta: {x: 325.1004, y: 100}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 402.3703, y: 131.0684}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &6630021293889268234
|
||||
CanvasRenderer:
|
||||
|
|
@ -2305,8 +2305,8 @@ RectTransform:
|
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 11.2}
|
||||
m_SizeDelta: {x: 100, y: 100}
|
||||
m_AnchoredPosition: {x: 2.4636, y: 4.4846}
|
||||
m_SizeDelta: {x: 350.9272, y: 108.97}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &7179199273450519475
|
||||
CanvasRenderer:
|
||||
|
|
@ -2338,12 +2338,12 @@ MonoBehaviour:
|
|||
m_Calls: []
|
||||
m_FontData:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_FontSize: 14
|
||||
m_FontSize: 18
|
||||
m_FontStyle: 0
|
||||
m_BestFit: 0
|
||||
m_MinSize: 10
|
||||
m_MinSize: 1
|
||||
m_MaxSize: 40
|
||||
m_Alignment: 4
|
||||
m_Alignment: 0
|
||||
m_AlignByGeometry: 0
|
||||
m_RichText: 1
|
||||
m_HorizontalOverflow: 0
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ public class Bumper : MonoBehaviour {
|
|||
// Is called whenever something collides with the bumper
|
||||
void OnTriggerEnter(Collider objectHit) {
|
||||
if (objectHit.transform.parent.gameObject.tag == "Player") {//Checks if the other object is the player
|
||||
|
||||
Debug.Log("Bump");
|
||||
PlayerMovement playerMovement = objectHit.GetComponent<PlayerMovement>();
|
||||
|
||||
float DirBumpX = playerMovement.driftVel.x * -1;//Inverts the Player Velocity x
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public class dGrapplingHook : NetworkBehaviour
|
|||
private float minSwingSpeed = 10;
|
||||
private float swingSpeed = 0;
|
||||
|
||||
private float swingMom = 40;
|
||||
private float swingMom = 50;
|
||||
private Vector3 tensionMomDirection;
|
||||
private Vector3 hookPointRight;
|
||||
private Vector3 momDirection;
|
||||
|
|
@ -34,7 +34,7 @@ public class dGrapplingHook : NetworkBehaviour
|
|||
private Vector3 oldXZDir;
|
||||
private float flip = -1; // flip variables for swing momentum
|
||||
private bool swingback = false; //swing the player back
|
||||
private float midpointMom;
|
||||
private float oldSwingMom;
|
||||
|
||||
Vector3 tensionDirection;
|
||||
float tensionForce;
|
||||
|
|
@ -67,6 +67,7 @@ public class dGrapplingHook : NetworkBehaviour
|
|||
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;
|
||||
oldSwingMom = swingMom;
|
||||
isGrappled = true; //toggle grappling state
|
||||
}
|
||||
}
|
||||
|
|
@ -176,27 +177,36 @@ public class dGrapplingHook : NetworkBehaviour
|
|||
return fDirection;
|
||||
}
|
||||
|
||||
//Needs to be Overhauled to properly implement energy loss and work more consistently taking into account players current Velocity, height and input
|
||||
//------Important Equations--------
|
||||
// TensionForce = Cos(theta) * g * m * Vector3(tensionDirection)
|
||||
// Potential Energy = m * g * h -- Will need to modify adding current speed
|
||||
// Kinetic Energy = 1/2 * m * V^2 -- assuming no energy loss at the bottom KE = PE at peak we will add energy loss ourselves
|
||||
// Total Energy = m * ((g*h) + (1/2 * V^2))
|
||||
// Velocity = (2 * ((TotalEnergy/m) - (g*h)))^(1/2) -- This hypothetically could be used for our swing momentum calculation
|
||||
// Movement Direction right angle of tension force = Sin(theta) * g * m * Vector3(Right angle to tensionDirection)
|
||||
Vector3 calculateMomentumDirection(float g, Vector3 hPoint){
|
||||
|
||||
tensionMomDirection = (hPoint - transform.position).normalized;
|
||||
hookPointRight = Vector3.Cross((new Vector3(hPoint.x,0,hPoint.z) - new Vector3(transform.position.x,0,transform.position.z)), transform.up).normalized;
|
||||
momDirection = flip * Vector3.Cross(hookPointRight, tensionMomDirection).normalized;
|
||||
hookPointRight = Vector3.Cross(oldXZDir, transform.up).normalized;
|
||||
momDirection = -1 * Vector3.Cross(hookPointRight, tensionMomDirection).normalized + new Vector3(.0001f,.0001f,.0001f);
|
||||
|
||||
if(oldXZDir != curXZDir && flip == -1){
|
||||
flip = 1;
|
||||
midpointMom = swingMom;
|
||||
//midpointMom = swingMom;
|
||||
swingback = false;
|
||||
Debug.Log("flip");
|
||||
}
|
||||
|
||||
if(swingback == false && swingMom <= (midpointMom*(.75f))){
|
||||
if(swingback == false && swingMom <= (oldSwingMom*(.75f))){
|
||||
swingback = true;
|
||||
flip = -1;
|
||||
oldSwingMom = swingMom;
|
||||
oldXZDir = (new Vector3(hookPoint.transform.position.x,0,hookPoint.transform.position.z) - new Vector3(transform.position.x,0,transform.position.z)).normalized;
|
||||
Debug.Log("swingback");
|
||||
}
|
||||
|
||||
curXZDir = (new Vector3(hPoint.x,0,hPoint.z) - new Vector3(transform.position.x,0,transform.position.z)).normalized;
|
||||
Debug.DrawRay(transform.position, momDirection * Time.deltaTime* 100, Color.green);
|
||||
Debug.Log((momDirection * swingMom).normalized);
|
||||
return (momDirection * Time.deltaTime * swingMom);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@ MonoBehaviour:
|
|||
m_EditorClassIdentifier:
|
||||
id: 11
|
||||
itemName: Dash
|
||||
description: Quickly Moves the player forwards
|
||||
description: Press F to quickly dash your player forward.
|
||||
itemSprite: {fileID: 0}
|
||||
maxVelM: 0
|
||||
minVelM: 0
|
||||
curVelM: 0
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ MonoBehaviour:
|
|||
m_EditorClassIdentifier:
|
||||
id: 7
|
||||
itemName: Glider
|
||||
description: Player Will Fall slower
|
||||
description: Hold space while falling to slow your descent.
|
||||
itemSprite: {fileID: 7798176430303134427, guid: 7f448051c9c906545bfd88ed2754392b, type: 3}
|
||||
maxVelM: 0
|
||||
minVelM: 0
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ MonoBehaviour:
|
|||
m_EditorClassIdentifier:
|
||||
id: 8
|
||||
itemName: Grapple
|
||||
description: Allows the use of a grapple
|
||||
description: Press E to grapple to a nearby grapple point.
|
||||
itemSprite: {fileID: -7389470788071104723, guid: 7f448051c9c906545bfd88ed2754392b, type: 3}
|
||||
maxVelM: 0
|
||||
minVelM: 0
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@ MonoBehaviour:
|
|||
m_EditorClassIdentifier:
|
||||
id: 10
|
||||
itemName: Nitro
|
||||
description: Boosts player speed
|
||||
description: Press Left Shift to boost your player speed beyond its max for a short
|
||||
period.
|
||||
itemSprite: {fileID: -295526885773654649, guid: 7f448051c9c906545bfd88ed2754392b, type: 3}
|
||||
maxVelM: 0
|
||||
minVelM: 0
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ MonoBehaviour:
|
|||
m_EditorClassIdentifier:
|
||||
id: 2
|
||||
itemName: Roller Skates
|
||||
description: More Slidey But Faster
|
||||
description: Increases your max speed and acceleration at the cost of traction.
|
||||
itemSprite: {fileID: -3696225328785611619, guid: 7f448051c9c906545bfd88ed2754392b, type: 3}
|
||||
maxVelM: 15
|
||||
minVelM: 0
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ MonoBehaviour:
|
|||
m_EditorClassIdentifier:
|
||||
id: 3
|
||||
itemName: Springs
|
||||
description: Jump Higher
|
||||
description: Your jumps will be more powerful.
|
||||
itemSprite: {fileID: 3996138432854981312, guid: 7f448051c9c906545bfd88ed2754392b, type: 3}
|
||||
maxVelM: 0
|
||||
minVelM: 0
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@ MonoBehaviour:
|
|||
m_EditorClassIdentifier:
|
||||
id: 4
|
||||
itemName: Strong Kick
|
||||
description: Kick Harder
|
||||
description: Your kick will become more powerful.
|
||||
itemSprite: {fileID: 0}
|
||||
maxVelM: 0
|
||||
minVelM: 0
|
||||
curVelM: 0
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@ MonoBehaviour:
|
|||
m_EditorClassIdentifier:
|
||||
id: 5
|
||||
itemName: Triple Jump
|
||||
description: Player gets an extra jump but has less jump height
|
||||
description: Your jump height will be reduced slightly but you will gain an extra
|
||||
jump.
|
||||
itemSprite: {fileID: -8809284872407378732, guid: 7f448051c9c906545bfd88ed2754392b, type: 3}
|
||||
maxVelM: 0
|
||||
minVelM: 0
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ MonoBehaviour:
|
|||
m_EditorClassIdentifier:
|
||||
id: 6
|
||||
itemName: Wall Run
|
||||
description: Allows player to run on walls
|
||||
description: You now have the ability to run across red walls.
|
||||
itemSprite: {fileID: -7634698977955767800, guid: 7f448051c9c906545bfd88ed2754392b, type: 3}
|
||||
maxVelM: 0
|
||||
minVelM: 0
|
||||
|
|
|
|||
|
|
@ -9,17 +9,17 @@ EditorUserSettings:
|
|||
value: 22424703114646680e0b0227036c78111b125507233d28242c20137df7ee3d2cfb
|
||||
flags: 0
|
||||
RecentlyUsedScenePath-1:
|
||||
value: 22424703114646680e0b0227036c7b151b180b6501273035202c1327d1e33136e7a923e7ee2e26
|
||||
value: 22424703114646680e0b0227036c6f02131b172b282d347e38271427fb
|
||||
flags: 0
|
||||
RecentlyUsedScenePath-2:
|
||||
value: 22424703114646680e0b0227036c6f02131b172b282d347e38271427fb
|
||||
flags: 0
|
||||
RecentlyUsedScenePath-3:
|
||||
value: 22424703114646680e0b0227036c731f1415016439262f2434
|
||||
flags: 0
|
||||
RecentlyUsedScenePath-4:
|
||||
RecentlyUsedScenePath-3:
|
||||
value: 22424703114646680e0b0227036c6f02131b172b282d347e38271427fb
|
||||
flags: 0
|
||||
RecentlyUsedScenePath-4:
|
||||
value: 22424703114646680e0b0227036c7b151b180b6501273035202c1327d1e33136e7a923e7ee2e26
|
||||
flags: 0
|
||||
vcSharedLogLevel:
|
||||
value: 0d5e400f0650
|
||||
flags: 0
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user