private void FixedUpdate()
{
animator.SetBool("blinking", _isBlinking);
if (!_isBlinking)
{
if (_timeRemaining > 0)
{
_timeRemaining -= Time.deltaTime;
}
else
{
_timeRemaining = 0;
_isBlinking = true;
animator.SetBool("persistantAttack", false);
}
}
if (transform.position.y < -0.64f)
{
transform.position = new Vector2(transform.position.x, -0.65f);
}
if (isOnGround() || !isOnBranch())
{
//shouldCrawl = false;
crawlMade = false;
isJumping = false;
animator.SetBool("climb", false);
//transform.rotation = Quaternion.AngleAxis(0, Vector3.forward);
}
//PropelTowardsPoint();
AllowLedgeClimb();
rb2D.constraints = RigidbodyConstraints2D.FreezeRotation;
// //flip character when when walking left or right
Vector3 characterScale = transform.localScale;
//input controls
Vector2 movementInput = moveAction.ReadValue();
if (transform.localScale.x == 1) { isFacingRight = true; }
else if (transform.localScale.x == -1) { isFacingRight = false; }
if (movementInput.x != 0)
{
characterScale.x = (movementInput.x < 0) ? System.Math.Abs(characterScale.x) * (-1) : System.Math.Abs(characterScale.x);
blinkingEnded();
}
if (movementInput.y > 0)
{
stopCrouching();
animator.SetBool("persistantAttack", false);
//AllowLedgeClimb();
if ((isOnGround() || boxCollider.IsTouchingLayers(branchLayerMask)) && !isPlaying(animator, "heroLedgeClimb"))
{
//animator.SetBool("climb", false);
_jumpDelayed += Time.deltaTime;
if (_jumpDelayed > _jumpDelay)
{
Debug.Log("regular jump");
rb2D.AddForce(new Vector2(0, JumpForce), ForceMode2D.Impulse);
_jumpDelayed = 0;
}
isJumping = true;
}
else if (!isOnGround() || !isOnBranch())
{
clearFlipColliders();
//characterScale.x = (characterScale.x < 0) ? System.Math.Abs(characterScale.x) : System.Math.Abs(characterScale.x) * (-1);
if (isPlaying(animator, "climb"))
{
//rb2D.AddForce(new Vector2(characterScale.x * 3, JumpForce), ForceMode2D.Impulse);
}
//animator.SetBool("climb", true);
isJumping = false;
swordAttacking = false;
}
//else if(isPlaying(animator, "climb")){
// Debug.Log("back flip jump");
// clearFlipColliders();
// _jumpDelayed += Time.deltaTime;
// if(_jumpDelayed > _jumpDelay){
// rb2D.AddForce(new Vector2(characterScale.x*3, JumpForce), ForceMode2D.Impulse);
// _jumpDelayed = 0;
// }
// isJumping = true;
// }
//animator.SetBool("persistantAttack", false);
// }
// if(shouldCrawl){
// if(characterScale.x < 0){
// transform.rotation = Quaternion.AngleAxis(45, Vector3.forward);
// }else{
// transform.rotation = Quaternion.AngleAxis(-45, Vector3.forward);
// }
// transform.position = Vector2.MoveTowards(transform.position, crawlToHere, MovementSpeed * Time.deltaTime);
// Vector2 curPos = new Vector2(transform.position.x, transform.position.y);
// if(curPos == crawlToHere){
// shouldCrawl = false;
// crawlMade = false;
// transform.rotation = Quaternion.AngleAxis(0, Vector3.forward);
// }
// }
}
Leave a Reply