Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        float targetSpeed = Input.GetAxisRaw("Vertical") * speed;

        currentSpeed = MovementHelpers.IncrementToward(currentSpeed, targetSpeed, acceleration);

        Vector2 amountToMove = new Vector2(0, currentSpeed);

        playerPhysics.Move(amountToMove * Time.deltaTime);
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (!GameProperties.GetCurrentGame().gameStarted)
        {
            return;
        }

        GameObject ball = GameObject.FindGameObjectWithTag("Ball");

        float distance    = ball.transform.position.y - transform.position.y;
        float targetSpeed = Mathf.Sign(distance) * speed;

        if (Mathf.Abs(distance) < slowThreshold)
        {
            targetSpeed /= slowCurve;
        }


        currentSpeed = MovementHelpers.IncrementToward(currentSpeed, targetSpeed, acceleration);

        Vector2 amountToMove = new Vector2(0, currentSpeed);

        AIPhysics.Move(amountToMove * Time.deltaTime);
    }