Diffrent behaviour in diffrent FPS

Hi i have a script that throws object below. For example in 10FPS it throws with a lot of power but in like 200FPS it throws with normal power. I multiple some values with time*deltatime to fix that but its not working what is the problem can you help me

    void Update()
    {
        ThrowPress();
    }
    private void ThrowPress()
    {
        if (CurrentObject == null)
        {
            return;
        }
        if (Input.GetKey(KeyCode.G))
        {
            if (currentThrowForce <= maxThrowForce)
            {
                currentThrowForce += ThrowIncreaseSpeed * Time.deltaTime;
                if (currentThrowForce >= maxThrowForce/8)
                {
                    ThrowBar.gameObject.SetActive(true);
                }
                ThrowBar.value = currentThrowForce;
            }
        }
        if (currentThrowForce > maxThrowForce)
        {
            currentThrowForce = maxThrowForce;
        }

        if (Input.GetKeyUp(KeyCode.G))
        {
            ThrowAction();
        }
    }
    public void ThrowAction()
    {
        CurrentObject.velocity = CurrentObject.transform.forward*currentThrowForce*Time.deltaTime;

        CurrentObject.useGravity = true;
        CurrentObject.transform.parent = pickUpObjectHolder;
        CurrentObject.transform.rotation = CurrentObject.transform.rotation;
        foreach (Collider collider in CurrentObject.GetComponents<Collider>())
        {
            collider.enabled = true;
        }
        foreach (Collider collider in CurrentObject.GetComponentsInChildren<Collider>())
        {
            collider.enabled = true;
        }
        CurrentObject.isKinematic = false;
        CurrentObject = null;
        currentThrowForce = 0;
        ThrowBar.value = 0;
        ThrowBar.gameObject.SetActive(false);
        isObjectInHands = false;

        if (gunSC != null)
        {
            gunSC.enabled = false;
        }
        if (foodSC != null)
        {
            foodSC.enabled = false;
        }
        return;
    }

I think you want to use Time.fixedDeltaTime for this. Time.deltaTime is just the time from the last frame to the current one, which, like you noticed, varies based on framerate. Use Time.fixedDeltaTime, which is a (usually) constant.

1 Like

Oh thanks a lot i tried and it fixed my problem like you said thanks!