Obi Official Forum
'ObiCloth' does not contain a definition for 'VolumeConstraints' - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Cloth (https://obi.virtualmethodstudio.com/forum/forum-2.html)
+--- Thread: 'ObiCloth' does not contain a definition for 'VolumeConstraints' (/thread-2451.html)



'ObiCloth' does not contain a definition for 'VolumeConstraints' - yeyoya - 27-08-2020

Hey,

I've tried to use the code I found on Obi's website to add pressure to my object, but I got the following error message:

Assets/_Scripts/Inflator.cs(24,15): error CS1061: 'ObiCloth' does not contain a definition for 'VolumeConstraints' and no accessible extension method 'VolumeConstraints' accepting a first argument of type 'ObiCloth' could be found (are you missing a using directive or an assembly reference?)

Here is the code:

Code:
using UnityEngine;
using Obi;

[RequireComponent(typeof(ObiCloth))]
public class Inflator : MonoBehaviour {

    ObiCloth cloth;

    public float inflationSpeed = 0.25f;
    public float maxPressure = 2;

    // Use this for initialization
    void Awake () {
        cloth = GetComponent<ObiCloth>();
    }

    // Update is called once per frame
    void Update () {
        cloth.VolumeConstraints.overpressure = Mathf.Min(cloth.VolumeConstraints.overpressure +
                                    Time.deltaTime*inflationSpeed,maxPressure);
        cloth.VolumeConstraints.PushDataToSolver();
    }
}

Many thanks


RE: 'ObiCloth' does not contain a definition for 'VolumeConstraints' - josemendez - 28-08-2020

Hi there,

You're looking at the docs for 3.X/4.X, there's no "VolumeConstraints" property in 5.X. You can now access global constraint properties directly (pressure, compliance, etc), see the API for the ObiCloth class:
http://obi.virtualmethodstudio.com/api.html

The correct code should be along the lines of:
Code:
cloth.pressure = <your new pressure>

See: http://obi.virtualmethodstudio.com/tutorials/volumeconstraints.html


RE: 'ObiCloth' does not contain a definition for 'VolumeConstraints' - yeyoya - 01-09-2020

(28-08-2020, 08:53 AM)josemendez Wrote: Hi there,

You're looking at the docs for 3.X/4.X, there's no "VolumeConstraints" property in 5.X. You can now access global constraint properties directly (pressure, compliance, etc), see the API for the ObiCloth class:
http://obi.virtualmethodstudio.com/api.html

The correct code should be along the lines of:
Code:
cloth.pressure = <your new pressure>

See: http://obi.virtualmethodstudio.com/tutorials/volumeconstraints.html

I must have found an older documentation.
It is working now. Many thanks!!!