private void FixedUpdate() { Vector2 velocity = m_rigidbody.velocity; targetHorizontalSpeed = horizontalInput * horizontalSpeed * (attacking ? attackMultiplier : 1); float diff = velocity.x - targetHorizontalSpeed; if (Mathf.Abs(diff) > acceleration) { velocity.x += (diff > 0 ? -1 : 1) * acceleration; } else { velocity.x = targetHorizontalSpeed; } if (!attacking && Mathf.Abs(horizontalInput) > 0.9f) { controller.UpdateFacingDirection(horizontalInput > 0 ? true : false); } if (!fallingThroughPlatform) { Physics2D.IgnoreLayerCollision(playerLayer, platformLayer, velocity.y > 0); } m_rigidbody.velocity = velocity; }
private void FixedUpdate() { Vector2 velocity = m_rigidbody.velocity; targetHorizontalSpeed = horizontalInput * horizontalSpeed * (attacking ? attackMultiplier : 1); float diff = velocity.x - targetHorizontalSpeed; if (Mathf.Abs(diff) > acceleration) { velocity.x += (diff > 0 ? -1 : 1) * acceleration; } else { velocity.x = targetHorizontalSpeed; } if (!attacking && Mathf.Abs(horizontalInput) > .9f) { controller.UpdateFacingDirection(horizontalInput > 0 ? true : false); } //horizontalMovement = horizontalInput * horizontalSpeed * Time.fixedDeltaTime; //if (targetHorizontalSpeed == 0) //{ // if (Mathf.Abs(velocity.x) > breakSpeed) // { // horizontalMovement -= velocity.normalized.x * breakSpeed; // } // else // { // horizontalMovement = 0; // } //} velocity.x *= (crouching ? crouchSpeedModifier : 1); //gambiarra temporária if (velocity.y > 0 && velocity.y < 1) { velocity.y = 0; } m_rigidbody.velocity = velocity; }
private void OnEnable() { slideFX.gameObject.SetActive(true); ParticleSystem.MainModule mainModule = slideFX.main; mainModule.startColor = zipline.GetComponent <SpriteRenderer>().color; slideFX.Play(); slideSFX.Play(); if (zipline) { controller.UpdateFacingDirection(zipline.Movement().x > 0); } m_animator.SetTrigger("Reset"); m_animator.SetBool("Airborne", true); StartCoroutine(JumpLock()); }