private void BounceOffWall() { if (RaycastHitInfo.HitWall(transform, out hit, distanceToWall, wallLayer)) { ps.Velocity = Vector3.Reflect(ps.Velocity, hit.normal) * wallVelocityDampener; } }
private void CalculateMoveDirection() { moveDirection = GetInputMoveDirection(); slopeAngle = CalculateSlopeAngle(out hit); if (slopeAngle > maxTraversableSlopeAngle + 90f || slopeAngle == 90f) { return; } if (moveDirection != Vector3.zero) { if (ps.IsGrounded) { moveDirection = Vector3.Cross(hit.normal, -transform.right); } else { if (RaycastHitInfo.HitWall(transform, out hit, distanceToWall, wallLayer)) { moveDirection = PlatformerPhysicsSim.WallHorizontalParallelDirection(transform, hit.normal, moveDirection); } } } }
private void MoveToward() { ps.UseGravity = false; if (hit.transform) { distanceToHookPoint = Vector3.Distance(hit.transform.position, ps.transform.position); } if (RaycastHitInfo.HitWall(ps.transform, out wallHit, wallCheckDistance, grappleLayer)) { //moveDirection = (angleMultiplier * Vector3.up - hit.normal).normalized; //moveDirection = PlatformerPhysicsSim.WallVerticalUpParallelDirection(ps.transform, hit.normal, moveDirection); moveDirection = PlatformerPhysicsSim.WallVerticalUpParallelDirection(ps.transform, hit.normal, directionToHookPoint); float value = maxHeightForGrapple - hookPoint.y; ps.Velocity = moveDirection * (bounceSpeedBoost + value); canMove = false; ps.UseGravity = true; } else { float speed = 0; directionToHookPoint = (hookPoint - ps.transform.position).normalized; if (distanceToHookPoint > constantSpeedDistance) { speed = distanceToHookPoint * distanceToAccelerationMult; ps.Velocity = speed * directionToHookPoint * Time.deltaTime; } else { speed = constantSpeedDistance * distanceToAccelerationMult; ps.Velocity = speed * directionToHookPoint * Time.deltaTime; } ps.Velocity = Vector3.ClampMagnitude(ps.Velocity, maxMoveSpeed); } }