Esempio n. 1
0
    void Update()
    {
        if (m_controller.Collisions.above || m_controller.Collisions.below)
        {
            m_velocity.y = 0;
        }

        Vector2 input = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));

        if (Input.GetKeyDown(KeyCode.Space) && m_controller.Collisions.below)
        {
            m_velocity.y = m_jumpVelocity;
        }

        float targetVelocityX = input.x * m_moveSpeed;

        m_velocity.x  = Mathf.SmoothDamp(m_velocity.x, targetVelocityX, ref m_velocityXSmoothing, (m_controller.Collisions.below) ? m_accelerationTimeGrounded : m_accelerationTimeAirbone);
        m_velocity.y += m_gravity * Time.deltaTime;
        m_controller.Move(m_velocity * Time.deltaTime);
    }
Esempio n. 2
0
 private void FixedUpdate()
 {
     controller.Move(_horizontalMove * Time.fixedDeltaTime, false, _jump);
     _jump = false;
 }