Beispiel #1
0
 void LateUpdate()
 {
     if (target)
     {
         float x = PhysicsUtils.IncrementTowards(transform.position.x, target.position.x, trackSpeed);
         float y = PhysicsUtils.IncrementTowards(transform.position.y, target.position.y, trackSpeed);
         transform.position = new Vector3(x, y, transform.position.z);
     }
 }
    void Update()
    {
        targetSpeed  = getHorizontalMovement() * speed;
        currentSpeed = PhysicsUtils.IncrementTowards(currentSpeed, targetSpeed, acceleration);

        if (playerPhysics.grounded)
        {
            amountToMove.y = 0;

            if (isJumping())
            {
                amountToMove.y = jumpHeight;
            }
        }

        amountToMove.x  = currentSpeed;
        amountToMove.y -= gravity * Time.deltaTime;
        playerPhysics.Move(amountToMove * Time.deltaTime);
    }