'How to edit Constant Force Component's relative force's values?

I am trying to make a pool table game. In this functionality; the force applied on the pool stick is proportional to the value of a constantly increasing power bar (mSlider), and when the left mouse button (Fire1) is pressed, the value of the slider (which is between 0 and 1) is multiplied to the max power (which is 800). This value is then applied to the relative force of the pool stick. The default relative force of the stick (on start) is the max of 800.

This is my code so far:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class powerBar : MonoBehaviour
{
    Image powerBarImage;
    float maxPower = 800f;

    public Slider mSlider;

    public Rigidbody rb;
    public GameObject stick;
    // Start is called before the first frame update
    void Start()
    {
        mSlider.maxValue = 1.0f;
        mSlider.value = 0f;
        powerBarImage = GetComponent<Image>();
        rb = stick.GetComponent<Rigidbody>();
    }

    // Update is called once per frame
    void Update()
    {
        if (mSlider.value == 1)
        {
            mSlider.value = 0f;
        }
        else
        {
            mSlider.value += 0.0025f;
            
        }
        //Debug.Log(mSlider.value);

        if (Input.GetButtonUp("Fire1"))
        {
            Debug.Log(maxPower * mSlider.value);
            

        }
    }
}

my problem is that i have been searching the internet for almost too long now on how to set a rigidbody's relative force. All I am seeing is setting or adding its force instead. Have I missed something?



Solution 1:[1]

I found it, its

rb.GetComponent<ConstantForce>().relativeForce = new Vector3(x, y, z);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 derHugo