mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-04-26 18:17:31 -05:00
Grappling Hook Alpha
-Impact based grappling hook with options for other types of implementation -Wallrun tweaked so players can always jump off wall
This commit is contained in:
parent
cc99ababff
commit
3e245ead44
|
|
@ -377,6 +377,101 @@ Transform:
|
|||
m_Father: {fileID: 944325791}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 25, y: 0, z: 0}
|
||||
--- !u!1 &529067475
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 529067479}
|
||||
- component: {fileID: 529067478}
|
||||
- component: {fileID: 529067477}
|
||||
- component: {fileID: 529067476}
|
||||
m_Layer: 0
|
||||
m_Name: Goal (1)
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!65 &529067476
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 529067475}
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 1, y: 1, z: 1}
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!23 &529067477
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 529067475}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 2
|
||||
m_RayTraceProcedural: 0
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_LightProbeVolumeOverride: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_ReceiveGI: 1
|
||||
m_PreserveUVs: 0
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
m_StitchLightmapSeams: 1
|
||||
m_SelectedEditorRenderState: 3
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_AdditionalVertexStreams: {fileID: 0}
|
||||
--- !u!33 &529067478
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 529067475}
|
||||
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!4 &529067479
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 529067475}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 208.1}
|
||||
m_LocalScale: {x: 10, y: 1, z: 25}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 17
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &605052955
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -466,8 +561,8 @@ Transform:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 605052955}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -8.16, y: 2.89, z: 70.8}
|
||||
m_LocalScale: {x: 1, y: 10, z: 20}
|
||||
m_LocalPosition: {x: -6.4, y: 2.89, z: 128.04}
|
||||
m_LocalScale: {x: 1, y: 10, z: 30}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 10
|
||||
|
|
@ -641,7 +736,7 @@ Transform:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 897829471}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 45, y: 12, z: 0}
|
||||
m_LocalPosition: {x: 70, y: 12, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
|
|
@ -660,6 +755,7 @@ GameObject:
|
|||
- component: {fileID: 944325789}
|
||||
- component: {fileID: 944325788}
|
||||
- component: {fileID: 944325787}
|
||||
- component: {fileID: 944325796}
|
||||
- component: {fileID: 944325792}
|
||||
- component: {fileID: 944325786}
|
||||
- component: {fileID: 944325794}
|
||||
|
|
@ -800,6 +896,23 @@ MonoBehaviour:
|
|||
m_Script: {fileID: 11500000, guid: addc2e37ff81c1b4989ec34b6150b4f7, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
maxVel: 25
|
||||
minVel: 2
|
||||
curVel: 0
|
||||
acc: 0.1
|
||||
jumpPow: 300
|
||||
jumpNum: 2
|
||||
traction: 3
|
||||
kickPow: 0
|
||||
recovTime: 0
|
||||
playerGrav: 20
|
||||
hasBlink: 0
|
||||
hasGlider: 0
|
||||
hasGrapple: 0
|
||||
hasWallrun: 0
|
||||
hasNitro: 0
|
||||
hasDash: 0
|
||||
playerPoints: 15
|
||||
--- !u!114 &944325793
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -828,7 +941,6 @@ MonoBehaviour:
|
|||
m_EditorClassIdentifier:
|
||||
items: []
|
||||
pStats: {fileID: 944325792}
|
||||
invMan: {fileID: 0}
|
||||
--- !u!114 &944325795
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -850,6 +962,22 @@ MonoBehaviour:
|
|||
wallBouncing: 3
|
||||
cameraTransitionDuration: 1
|
||||
wallGravityDownForce: 0
|
||||
--- !u!54 &944325796
|
||||
Rigidbody:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 944325785}
|
||||
serializedVersion: 2
|
||||
m_Mass: 1
|
||||
m_Drag: 0
|
||||
m_AngularDrag: 0.05
|
||||
m_UseGravity: 0
|
||||
m_IsKinematic: 1
|
||||
m_Interpolate: 0
|
||||
m_Constraints: 0
|
||||
m_CollisionDetection: 0
|
||||
--- !u!114 &944325797
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -1430,6 +1558,101 @@ Transform:
|
|||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 14
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1419369286
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1419369290}
|
||||
- component: {fileID: 1419369289}
|
||||
- component: {fileID: 1419369288}
|
||||
- component: {fileID: 1419369287}
|
||||
m_Layer: 0
|
||||
m_Name: Wall (3)
|
||||
m_TagString: WallRun
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!65 &1419369287
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1419369286}
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 1, y: 1, z: 1}
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!23 &1419369288
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1419369286}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 2
|
||||
m_RayTraceProcedural: 0
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: 730a2ba314caf9742823631b050afe28, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_LightProbeVolumeOverride: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_ReceiveGI: 1
|
||||
m_PreserveUVs: 0
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
m_StitchLightmapSeams: 1
|
||||
m_SelectedEditorRenderState: 3
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_AdditionalVertexStreams: {fileID: 0}
|
||||
--- !u!33 &1419369289
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1419369286}
|
||||
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!4 &1419369290
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1419369286}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -4.82, y: 2.89, z: 187.6}
|
||||
m_LocalScale: {x: 1, y: 10, z: 30}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 16
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1458711923
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -1614,8 +1837,8 @@ Transform:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1496353121}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -5.44, y: 2.89, z: 29.21}
|
||||
m_LocalScale: {x: 1, y: 10, z: 20}
|
||||
m_LocalPosition: {x: 6.6, y: 2.89, z: 156.1}
|
||||
m_LocalScale: {x: 1, y: 10, z: 35}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 3
|
||||
|
|
@ -1709,7 +1932,7 @@ Transform:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1586401853}
|
||||
m_LocalRotation: {x: 0, y: 0.7071068, z: 0, w: 0.7071068}
|
||||
m_LocalPosition: {x: 65, y: 0, z: 0}
|
||||
m_LocalPosition: {x: 85, y: 0, z: 0}
|
||||
m_LocalScale: {x: 10, y: 1, z: 10}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
|
|
@ -1897,8 +2120,8 @@ Transform:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1745259058}
|
||||
m_LocalRotation: {x: 0, y: 0.7071068, z: 0, w: 0.7071068}
|
||||
m_LocalPosition: {x: 25, y: 0, z: 0}
|
||||
m_LocalScale: {x: 10, y: 1, z: 10}
|
||||
m_LocalPosition: {x: 40, y: 0, z: 0}
|
||||
m_LocalScale: {x: 10, y: 1, z: 40}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 12
|
||||
|
|
|
|||
|
|
@ -12,11 +12,20 @@ public class GrapplingHook : MonoBehaviour
|
|||
private GameObject[] hookPoints;
|
||||
private float distance;
|
||||
|
||||
private CharacterController movementController;
|
||||
private PlayerMovement playerMovement;
|
||||
private PlayerStats pStats;
|
||||
private float ropeLength;
|
||||
private float climbRate = 5;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
isGrappled = false;
|
||||
hookPoints = GameObject.FindGameObjectsWithTag("HookPoint");
|
||||
movementController = gameObject.GetComponent<CharacterController>();
|
||||
playerMovement = gameObject.GetComponent<PlayerMovement>();
|
||||
pStats = gameObject.GetComponent<PlayerStats>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
|
|
@ -30,7 +39,7 @@ public class GrapplingHook : MonoBehaviour
|
|||
if (hookPointIndex != -1) //If there is a hookpoint
|
||||
{
|
||||
hookPoint = hookPoints[hookPointIndex]; //The point we are grappling from
|
||||
//physics set up?
|
||||
ropeLength = Vector3.Distance(gameObject.transform.position, hookPoint.transform.position) + 0.5f;
|
||||
isGrappled = true; //toggle grappling state
|
||||
}
|
||||
}
|
||||
|
|
@ -46,7 +55,35 @@ public class GrapplingHook : MonoBehaviour
|
|||
{
|
||||
if (isGrappled)
|
||||
{
|
||||
Debug.DrawRay(gameObject.transform.position, (hookPoint.transform.position - gameObject.transform.position)); //Visual of line
|
||||
|
||||
if (Input.GetKey(KeyCode.LeftShift)) //Extend hook
|
||||
{
|
||||
ropeLength += climbRate * Time.deltaTime;
|
||||
if (ropeLength > maxGrappleDistance)
|
||||
{
|
||||
ropeLength = maxGrappleDistance;
|
||||
}
|
||||
//Debug.Log(ropeLength.ToString());
|
||||
}
|
||||
if (Input.GetKey(KeyCode.RightShift)) // Retract Hook
|
||||
{
|
||||
ropeLength -= climbRate * Time.deltaTime;
|
||||
if (ropeLength < 5)
|
||||
{
|
||||
ropeLength = 5;
|
||||
}
|
||||
//Debug.Log(ropeLength.ToString());
|
||||
}
|
||||
//Do grappling physics based on hookPoint
|
||||
if (Vector3.Distance(gameObject.transform.position, hookPoint.transform.position) > ropeLength)
|
||||
{
|
||||
//Impact Based
|
||||
playerMovement.AddImpact((hookPoint.transform.position - gameObject.transform.position), pStats.PlayerGrav);
|
||||
//Character controller move?
|
||||
//movementController.Move((hookPoint.transform.position - gameObject.transform.position).normalized * ropeLength*Time.deltaTime);
|
||||
//Lerp? or another smoother way? Better physics? Wait until refinement to deal with
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ using UnityEngine;
|
|||
|
||||
public class WallRunItem : Item
|
||||
{
|
||||
public void Equip(PlayerStats p){
|
||||
public override void Equip(PlayerStats p){
|
||||
p.HasWallrun = true;
|
||||
}
|
||||
|
||||
public void Unequip(PlayerStats p)
|
||||
public override void Unequip(PlayerStats p)
|
||||
{
|
||||
p.HasWallrun = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ public class PlayerMovement : MonoBehaviour
|
|||
cam = GetComponentInChildren<Camera>();
|
||||
|
||||
//Wallrun
|
||||
//wallRun = gameObject.GetComponent<WallRun>();
|
||||
wallRun = gameObject.GetComponent<WallRun>();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -118,7 +118,7 @@ public class PlayerMovement : MonoBehaviour
|
|||
}
|
||||
|
||||
//Checks if player should respawn
|
||||
Respawn();
|
||||
//Respawn();
|
||||
|
||||
|
||||
|
||||
|
|
@ -237,6 +237,11 @@ public class PlayerMovement : MonoBehaviour
|
|||
vel = newVelocity;
|
||||
}
|
||||
|
||||
public void decrementCurrentJumpNumber()
|
||||
{
|
||||
curJumpNum--;
|
||||
}
|
||||
|
||||
//Camera
|
||||
private void Rotate()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ public class WallRun : MonoBehaviour
|
|||
float elapsedTimeSinceWallAttach = 0;
|
||||
float elapsedTimeSinceWallDetatch = 0;
|
||||
bool jumping;
|
||||
private bool regainedJump = false;
|
||||
|
||||
bool isPlayergrounded() => playerMovementController.isGrounded;
|
||||
|
||||
|
|
@ -111,11 +112,17 @@ public class WallRun : MonoBehaviour
|
|||
elapsedTimeSinceWallDetatch = 0;
|
||||
elapsedTimeSinceWallAttach += Time.deltaTime;
|
||||
playerMovementController.AddPlayerVelocity((Vector3.down * wallGravityDownForce * Time.deltaTime));
|
||||
if (elapsedTimeSinceWallAttach > 0.125f && regainedJump == false)//Allows players to always jump off of walls
|
||||
{
|
||||
regainedJump = true;
|
||||
playerMovementController.decrementCurrentJumpNumber();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
elapsedTimeSinceWallAttach = 0;
|
||||
elapsedTimeSinceWallDetatch += Time.deltaTime;
|
||||
regainedJump = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -147,8 +154,9 @@ public class WallRun : MonoBehaviour
|
|||
|
||||
Vector3 moveToSet = alongWall * vertical * playerMovementController.PlayerSpeed() *Time.deltaTime;// * wallSpeedMultiplier;
|
||||
moveToSet.y = 0;
|
||||
|
||||
Vector3 cancelDrop = new Vector3(0, 0.01f, 0);
|
||||
playerMovementController.SetPlayerVelocity(moveToSet);
|
||||
playerMovementController.AddPlayerVelocity(cancelDrop);
|
||||
//Debug.Log("On Wall");
|
||||
isWallRunning = true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user