From e91afb02f4c077046d354a0c740ac8d6137913fd Mon Sep 17 00:00:00 2001 From: Melbyj1125 <60886701+Melbyj1125@users.noreply.github.com> Date: Fri, 10 Dec 2021 12:34:13 -0600 Subject: [PATCH] Bumper has been fixed sort of You need to use 2 colliders one thats a trigger and one thats not and it will work properly --- Assets/Scenes/Demos/MovementScene.unity | 249 +++++++++++++++++- Assets/Scripts/KingAbilities/Bumper.cs | 16 +- .../DebugPlayer/DebugItems/dDash.cs | 6 + .../DebugPlayer/DebugItems/dGrapplingHook.cs | 4 +- .../DebugPlayer/dPlayerMovement.cs | 27 +- .../PlayerItems/ItemScripts/GrapplingHook.cs | 2 +- 6 files changed, 274 insertions(+), 30 deletions(-) diff --git a/Assets/Scenes/Demos/MovementScene.unity b/Assets/Scenes/Demos/MovementScene.unity index 109f4bc..e0ccd6a 100644 --- a/Assets/Scenes/Demos/MovementScene.unity +++ b/Assets/Scenes/Demos/MovementScene.unity @@ -929,6 +929,148 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} +--- !u!1 &1181153597 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1181153602} + - component: {fileID: 1181153601} + - component: {fileID: 1181153600} + - component: {fileID: 1181153599} + - component: {fileID: 1181153598} + - component: {fileID: 1181153604} + - component: {fileID: 1181153603} + m_Layer: 0 + m_Name: Bumper + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1181153598 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1181153597} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 204dc1e4ca638924caabaa45df29d9d1, type: 3} + m_Name: + m_EditorClassIdentifier: + bumpPower: 20 +--- !u!136 &1181153599 +CapsuleCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1181153597} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + m_Radius: 0.49 + m_Height: 0.1 + m_Direction: 1 + m_Center: {x: 0.000000059604645, y: 0, z: -0.00000008940697} +--- !u!23 &1181153600 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1181153597} + 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 &1181153601 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1181153597} + m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &1181153602 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1181153597} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 2.5, y: 1, z: 41.95} + m_LocalScale: {x: 5, y: 1, z: 5} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 7 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!136 &1181153603 +CapsuleCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1181153597} + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_Enabled: 1 + m_Radius: 0.58 + m_Height: 2 + m_Direction: 1 + m_Center: {x: 0.000000059604645, y: 0, z: -0.00000008940697} +--- !u!54 &1181153604 +Rigidbody: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1181153597} + serializedVersion: 2 + m_Mass: 1 + m_Drag: 0 + m_AngularDrag: 0.05 + m_UseGravity: 1 + m_IsKinematic: 0 + m_Interpolate: 0 + m_Constraints: 0 + m_CollisionDetection: 0 --- !u!1001 &1212970163 PrefabInstance: m_ObjectHideFlags: 0 @@ -952,6 +1094,10 @@ PrefabInstance: propertyPath: m_Name value: DebugPlayerPrefab objectReference: {fileID: 0} + - target: {fileID: 5784126162129930074, guid: 362ca97b75c291a47ab81d628a81f440, type: 3} + propertyPath: dashItem + value: + objectReference: {fileID: 11400000, guid: 4399d7276b3edf446ac51c5145539a5e, type: 2} - target: {fileID: 6743056025486776975, guid: 362ca97b75c291a47ab81d628a81f440, type: 3} propertyPath: fallMultiplier value: 1.5 @@ -1010,19 +1156,19 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 8100520363622627413, guid: 362ca97b75c291a47ab81d628a81f440, type: 3} propertyPath: acc - value: 0.1 + value: 0.01 objectReference: {fileID: 0} - target: {fileID: 8100520363622627413, guid: 362ca97b75c291a47ab81d628a81f440, type: 3} propertyPath: maxVel - value: 30 + value: 40 objectReference: {fileID: 0} - target: {fileID: 8100520363622627413, guid: 362ca97b75c291a47ab81d628a81f440, type: 3} propertyPath: minVel - value: 5 + value: 15 objectReference: {fileID: 0} - target: {fileID: 8100520363622627413, guid: 362ca97b75c291a47ab81d628a81f440, type: 3} propertyPath: jumpPow - value: 63 + value: 60 objectReference: {fileID: 0} - target: {fileID: 8100520363622627413, guid: 362ca97b75c291a47ab81d628a81f440, type: 3} propertyPath: kickPow @@ -1228,6 +1374,101 @@ Transform: m_Father: {fileID: 1493944131} m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1405946429 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1405946433} + - component: {fileID: 1405946432} + - component: {fileID: 1405946431} + - component: {fileID: 1405946430} + m_Layer: 0 + m_Name: Sphere + m_TagString: HookPoint + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!135 &1405946430 +SphereCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1405946429} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Radius: 0.5 + m_Center: {x: 0, y: 0, z: 0} +--- !u!23 &1405946431 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1405946429} + 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 &1405946432 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1405946429} + m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &1405946433 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1405946429} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -1.5, y: 14.2, z: 10.3} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 6 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1493944130 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/KingAbilities/Bumper.cs b/Assets/Scripts/KingAbilities/Bumper.cs index 4e7002e..d1a82a0 100644 --- a/Assets/Scripts/KingAbilities/Bumper.cs +++ b/Assets/Scripts/KingAbilities/Bumper.cs @@ -4,15 +4,17 @@ using UnityEngine; public class Bumper : MonoBehaviour { + public float bumpPower = 80; + // Is called whenever something collides with the bumper - void OnTriggerEnter(Collider other) { - Debug.Log("Bump!"); - if (other.tag == "Player") {//Checks if the other object is the player - float DirBumpX = other.GetComponent().vel.x * -1;//Inverts the Player Velocity x - float DirBumpZ = other.GetComponent().vel.z * -1;//Inverts the Player Velocity y - Vector3 DirBump = new Vector3(DirBumpX, .01f, DirBumpZ);//Creates a direction to launch the player + void OnTriggerEnter(Collider objectHit) { + if (objectHit.tag == "Player") {//Checks if the other object is the player + dPlayerMovement playerMovement = objectHit.GetComponent(); + float DirBumpX = playerMovement.vel.x * -1;//Inverts the Player Velocity x + float DirBumpZ = playerMovement.vel.z * -1;//Inverts the Player Velocity y + Vector3 DirBump = new Vector3(DirBumpX, .1f, DirBumpZ);//Creates a direction to launch the player DirBump = Vector3.Normalize(DirBump);//Normalizes the vector to be used as a bump direction - other.GetComponent().GetHit(DirBump, 50); //Launches tthe player directly away from the bumper + playerMovement.GetHit(DirBump, bumpPower); //Launches tthe player directly away from the bumper } } } diff --git a/Assets/Scripts/PlayerScripts/DebugPlayer/DebugItems/dDash.cs b/Assets/Scripts/PlayerScripts/DebugPlayer/DebugItems/dDash.cs index a645ffc..43f45f4 100644 --- a/Assets/Scripts/PlayerScripts/DebugPlayer/DebugItems/dDash.cs +++ b/Assets/Scripts/PlayerScripts/DebugPlayer/DebugItems/dDash.cs @@ -16,13 +16,19 @@ public class dDash : NetworkBehaviour{ float dashSpeed = 12; CharacterController characterController; + dPlayerMovement pMove; void Start(){ characterController = this.gameObject.GetComponent(); + pMove = GetComponent(); } //UPDATE CHECK FOR MOVEMENT ONLY WHEN DASHING void FixedUpdate(){ + if(pMove.pStats.HasDash) Dash(); + } + + void Dash(){ //if (!IsLocalPlayer) { return; } if(characterController.enabled == true){ if (Input.GetKeyDown(KeyCode.E) && isOnCoolDown == false) diff --git a/Assets/Scripts/PlayerScripts/DebugPlayer/DebugItems/dGrapplingHook.cs b/Assets/Scripts/PlayerScripts/DebugPlayer/DebugItems/dGrapplingHook.cs index daecd19..1591fd8 100644 --- a/Assets/Scripts/PlayerScripts/DebugPlayer/DebugItems/dGrapplingHook.cs +++ b/Assets/Scripts/PlayerScripts/DebugPlayer/DebugItems/dGrapplingHook.cs @@ -84,9 +84,9 @@ public class dGrapplingHook : NetworkBehaviour if (Vector3.Distance(gameObject.transform.position, hookPoint.transform.position) > ropeLength) { //Impact Based - playerMovement.AddImpact((hookPoint.transform.position - gameObject.transform.position), pStats.PlayerGrav); + //playerMovement.AddImpact((hookPoint.transform.position - gameObject.transform.position), pStats.PlayerGrav*2); //Character controller move? - //movementController.Move((hookPoint.transform.position - gameObject.transform.position).normalized * ropeLength*Time.deltaTime); + movementController.Move((hookPoint.transform.position - gameObject.transform.position).normalized * ropeLength * 10 *Time.deltaTime); //Lerp? or another smoother way? Better physics? Wait until refinement to deal with } } diff --git a/Assets/Scripts/PlayerScripts/DebugPlayer/dPlayerMovement.cs b/Assets/Scripts/PlayerScripts/DebugPlayer/dPlayerMovement.cs index 618f151..fb4f9cc 100644 --- a/Assets/Scripts/PlayerScripts/DebugPlayer/dPlayerMovement.cs +++ b/Assets/Scripts/PlayerScripts/DebugPlayer/dPlayerMovement.cs @@ -29,7 +29,7 @@ public class dPlayerMovement : NetworkBehaviour //Jump value public int curJumpNum; // current Jumps used private bool jumpHeld; // Is jump being held - float coyJumpTimer = 0.2f; // Default Coyote Jump time + float coyJumpTimer = 0.1f; // Default Coyote Jump time float curCoyJumpTimer; // current Coyote Jump time public float lowJumpMultiplier; // Short jump multiplier public float fallMultiplier; // High Jump Multiplier @@ -147,23 +147,18 @@ public class dPlayerMovement : NetworkBehaviour impact = Vector3.Lerp(impact, Vector3.zero, 5*Time.deltaTime); } - //TEMP FOR TESTING RAGDOLL - //Right Click to ragdoll the player - // if (Input.GetMouseButton(1) && heldDown == false){ - // getHit(new Vector3(vel.x, 0, vel.z), 30); - // heldDown = true; - // } - // if(!Input.GetMouseButton(1)){ - // heldDown = false; - // } + //If Character controller is disabled use rigidbody calculations + else{ + //if ragdoll timer is over disable ragdolling + if (RagdollTimer() == 0){ + firstHit = false; + DisableRagdoll(); + } - if(pStats.HasBlink == true){ - blink.BlinkMove(); + //Gravity without moveController + g -= pStats.PlayerGrav * Time.deltaTime; + rB.AddForce(new Vector3(0,g,0)); } - - //TEMP FOR TESTING - //Checks if player should respawn - //Respawn(); } diff --git a/Assets/Scripts/PlayerScripts/PlayerItems/ItemScripts/GrapplingHook.cs b/Assets/Scripts/PlayerScripts/PlayerItems/ItemScripts/GrapplingHook.cs index f8302e8..7282046 100644 --- a/Assets/Scripts/PlayerScripts/PlayerItems/ItemScripts/GrapplingHook.cs +++ b/Assets/Scripts/PlayerScripts/PlayerItems/ItemScripts/GrapplingHook.cs @@ -32,7 +32,7 @@ public class GrapplingHook : NetworkBehaviour // Update is called once per frame void Update() { - //if (!IsLocalPlayer) { return; } + if (!IsLocalPlayer) { return; } if (Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.JoystickButton2)) //If grapple button is hit {