Ejemplo n.º 1
0
    private void MoveSmoothly()
    {
        Vector2 targetVel = new Vector2(m_inputMove.x * MoveSpeed, m_inputMove.y * MoveSpeed);

        m_velocity.x = Mathf.SmoothDamp(m_velocity.x, targetVel.x, ref m_accelerationX, SMOOTH_TIME);
        m_velocity.y = Mathf.SmoothDamp(m_velocity.y, targetVel.y, ref m_accelerationY, SMOOTH_TIME);
        m_physics.Move(m_velocity, m_inputMove);
    }
Ejemplo n.º 2
0
    void Update()
    {
        if (IsCurrentPlayer)
        {
            playerMovement();
        }
        else
        {
            npcMovement();
        }
        //m_physics logic
        float targetVelocityX = inputX * MoveSpeed;
        float targetVelocityY = inputY * MoveSpeed;

        Velocity.x = Mathf.SmoothDamp(Velocity.x, targetVelocityX, ref m_velocityXSmoothing, m_accel);
        Velocity.y = Mathf.SmoothDamp(Velocity.y, targetVelocityY, ref m_velocityYSmoothing, m_accel);
        Vector2 input = new Vector2(inputX, inputY);

        m_physics.Move(Velocity, input);
        m_physics.AttemptingMovement = (inputX != 0.0f || inputY != 0.0f);
    }