Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
'ObiCloth' does not contain a definition for 'VolumeConstraints'
#1
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
Reply
#2
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/tutor...aints.html
Reply
#3
(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/tutor...aints.html

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