grapple still has issues

This commit is contained in:
Melbyj1125 2021-12-10 18:05:54 -06:00
parent 45ce1576b5
commit 4c8cbcf82e
5 changed files with 42 additions and 83 deletions

View File

@ -1078,38 +1078,10 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 1818923263116056088, guid: 362ca97b75c291a47ab81d628a81f440, type: 3}
propertyPath: wallMaxDistance
value: 0.8
objectReference: {fileID: 0}
- target: {fileID: 2782774462923692506, guid: 362ca97b75c291a47ab81d628a81f440, type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3607330906377400225, guid: 362ca97b75c291a47ab81d628a81f440, type: 3}
propertyPath: m_TagString
value: Player
objectReference: {fileID: 0}
- target: {fileID: 5633209979457551608, guid: 362ca97b75c291a47ab81d628a81f440, type: 3}
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
objectReference: {fileID: 0}
- target: {fileID: 6743056025486776975, guid: 362ca97b75c291a47ab81d628a81f440, type: 3}
propertyPath: lowJumpMultiplier
value: 0.3
objectReference: {fileID: 0}
- target: {fileID: 6743056025486776975, guid: 362ca97b75c291a47ab81d628a81f440, type: 3}
propertyPath: groundCheckHitbox.m_Bits
value: 8
objectReference: {fileID: 0}
- target: {fileID: 6926740475113451123, guid: 362ca97b75c291a47ab81d628a81f440, type: 3}
propertyPath: m_RootOrder
value: 4
@ -1154,34 +1126,6 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8100520363622627413, guid: 362ca97b75c291a47ab81d628a81f440, type: 3}
propertyPath: acc
value: 0.01
objectReference: {fileID: 0}
- target: {fileID: 8100520363622627413, guid: 362ca97b75c291a47ab81d628a81f440, type: 3}
propertyPath: maxVel
value: 40
objectReference: {fileID: 0}
- target: {fileID: 8100520363622627413, guid: 362ca97b75c291a47ab81d628a81f440, type: 3}
propertyPath: minVel
value: 15
objectReference: {fileID: 0}
- target: {fileID: 8100520363622627413, guid: 362ca97b75c291a47ab81d628a81f440, type: 3}
propertyPath: jumpPow
value: 60
objectReference: {fileID: 0}
- target: {fileID: 8100520363622627413, guid: 362ca97b75c291a47ab81d628a81f440, type: 3}
propertyPath: kickPow
value: 150
objectReference: {fileID: 0}
- target: {fileID: 8100520363622627413, guid: 362ca97b75c291a47ab81d628a81f440, type: 3}
propertyPath: hasWallrun
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8100520363622627413, guid: 362ca97b75c291a47ab81d628a81f440, type: 3}
propertyPath: playerGrav
value: 200
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 362ca97b75c291a47ab81d628a81f440, type: 3}
--- !u!1 &1257935739
@ -1463,7 +1407,7 @@ Transform:
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_LocalPosition: {x: -1.5, y: 23.9, z: 10.3}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}

View File

@ -10,11 +10,15 @@ public class Bumper : MonoBehaviour {
void OnTriggerEnter(Collider objectHit) {
if (objectHit.tag == "Player") {//Checks if the other object is the player
dPlayerMovement playerMovement = objectHit.GetComponent<dPlayerMovement>();
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
float DirBumpX = playerMovement.driftVel.x * -1;//Inverts the Player Velocity x
float DirBumpY = .1f;
float DirBumpZ = playerMovement.driftVel.z * -1;//Inverts the Player Velocity z
Vector3 DirBump = new Vector3(DirBumpX, DirBumpY, DirBumpZ);//Creates a direction to launch the player
DirBump = Vector3.Normalize(DirBump);//Normalizes the vector to be used as a bump direction
playerMovement.GetHit(DirBump, bumpPower); //Launches tthe player directly away from the bumper
playerMovement.GetHit(DirBump, bumpPower);
}
}
}

View File

@ -7,7 +7,7 @@ public class dGrapplingHook : NetworkBehaviour
{
public float maxGrappleDistance = 25;
private bool isGrappled;
public bool isGrappled;
private int hookPointIndex;
private GameObject hookPoint;
private GameObject[] hookPoints;
@ -16,7 +16,8 @@ public class dGrapplingHook : NetworkBehaviour
private CharacterController movementController;
private dPlayerMovement playerMovement;
private PlayerStats pStats;
private float ropeLength;
private Vector3 hookLerp;
public float ropeLength;
private float climbRate = 5;
// Start is called before the first frame update
@ -83,13 +84,15 @@ public class dGrapplingHook : NetworkBehaviour
//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*2);
movementController.Move((hookPoint.transform.position - gameObject.transform.position).normalized * Time.deltaTime);
//Character controller move?
movementController.Move((hookPoint.transform.position - gameObject.transform.position).normalized * ropeLength * 10 *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
}
}
if(playerMovement.GetJumpPressed()){
isGrappled = false;
}
}
int FindHookPoint()

View File

@ -17,8 +17,7 @@ public class dPlayerMovement : NetworkBehaviour
private Vector3 moveZ;
private Vector3 moveX;
private Vector3 driftVel;
private Vector3 lerpY;
public Vector3 driftVel;
//Player prefab
private GameObject parentObj;
@ -79,7 +78,7 @@ public class dPlayerMovement : NetworkBehaviour
private Vector3 hitForce;
//Slide Variables
private bool isSliding = false;
public bool isSliding = false;
private float originalTraction;
private RaycastHit ray;
private Vector3 up;
@ -87,6 +86,8 @@ public class dPlayerMovement : NetworkBehaviour
//Blink
private dBlink blink;
private dGrapplingHook grapple;
//Animation controller
@ -106,6 +107,7 @@ public class dPlayerMovement : NetworkBehaviour
pStats = GetComponent<PlayerStats>(); // PlayerStats
wallRun = GetComponent<dWallRun>(); //Wallrun
blink = GetComponent<dBlink>(); //Blink
grapple = GetComponent<dGrapplingHook>();
//Get parents up direction
up = GetComponentInParent<Transform>().up;
@ -204,8 +206,9 @@ public class dPlayerMovement : NetworkBehaviour
if(animator != null) animator.SetBool("isRunning", true);
}
//if low enough movement from player (this will be still at this value) stop animation
else if (driftVel.magnitude < .510f)
else if (driftVel.magnitude < .05f)
{
driftVel = Vector3.zero;
if(animator != null) animator.SetBool("isRunning", false);
}
@ -266,7 +269,7 @@ public class dPlayerMovement : NetworkBehaviour
if (Input.GetAxis("Jump") != 0 && !jumpHeld && curJumpNum < pStats.JumpNum && !isSliding)
{
if(wallRun.IsWallRunning()){
AddImpact((wallRun.GetWallJumpDirection()), pStats.JumpPow * 20f);
AddImpact((wallRun.GetWallJumpDirection()), pStats.JumpPow * 10f);
g = pStats.JumpPow;
}
@ -380,9 +383,9 @@ public class dPlayerMovement : NetworkBehaviour
private void UpdateGravity(){
//Gliding
if(pStats.HasGlider && g < 0 && jumpHeld){
if(pStats.HasGlider && g < 0 && Input.GetButton("Jump")){
//Gravity with glider
GravityCalculation(10);
GravityCalculation(6);
//Set temp values to put traction back to normal
if(tempSet == false){
@ -425,22 +428,22 @@ public class dPlayerMovement : NetworkBehaviour
private void GravityCalculation(float grav){
//apply slight upwards force for jump smoothing when g < 0
if(g < 0){
g += grav * (fallMultiplier - 1) * Time.deltaTime;
g += grav * (fallMultiplier - 1) * Time.deltaTime;
}
//apply smaller upwards force if jump is released early when jumping creating a short jump
else if (g > 0 && !Input.GetButton("Jump")){
g += grav * (lowJumpMultiplier - 1) * Time.deltaTime;
g += grav * (lowJumpMultiplier - 1) * Time.deltaTime;
}
//apply gravity if not grounded and coyote timer is less than 0
if(isGrounded == false && curCoyJumpTimer <= 0){
g -= grav * Time.deltaTime;
if((isGrounded == false && curCoyJumpTimer <= 0) || (!grapple.isGrappled && isGrounded == false)){
g -= grav * Time.deltaTime;
}
//else don't apply gravity
else{
g = 0;
g = 0;
}
}
@ -462,7 +465,7 @@ public class dPlayerMovement : NetworkBehaviour
{
isGrounded = true;
// handle snapping to the ground
if (groundHit.distance > moveController.skinWidth)
if (groundHit.distance > moveController.skinWidth && !grapple.isGrappled)
{
moveController.Move(Vector3.down * groundHit.distance);
}
@ -494,6 +497,7 @@ public class dPlayerMovement : NetworkBehaviour
rB.isKinematic = true;
rB.detectCollisions = false;
transform.localEulerAngles = prevRot;
CancelMomentum();
}
//When to begin the ragdoll timer
@ -556,7 +560,7 @@ public class dPlayerMovement : NetworkBehaviour
vel = Vector3.zero;
moveX = Vector3.zero;
moveZ = Vector3.zero;
moveController.enabled = false;
driftVel = Vector3.zero;
}
private IEnumerator RespawnTimer()
@ -571,4 +575,8 @@ public class dPlayerMovement : NetworkBehaviour
moveController.enabled = true;
}
public void TeleportPlayer(){
}
}

View File

@ -390,9 +390,9 @@ public class PlayerMovement : NetworkBehaviour
private void UpdateGravity(){
//Gliding
if(pStats.HasGlider && g < 0 && jumpHeld){
if(pStats.HasGlider && g < 0 && Input.GetButton("Jump")){
//Gravity with glider
GravityCalculation(10);
GravityCalculation(6);
//Set temp values to put traction back to normal
if(tempSet == false){
@ -444,7 +444,7 @@ public class PlayerMovement : NetworkBehaviour
}
//apply gravity if not grounded and coyote timer is less than 0
if(isGrounded == false && curCoyJumpTimer <= 0){
if((isGrounded == false && curCoyJumpTimer <= 0)){
g -= grav * Time.deltaTime;
}