constant force reference

Hi
I’ve added constant force in unity and with:
ConstantForce.relativeForce = Vector3(0,-200,0);
I get:

Assets/myUnderwater.cs(85,47): error CS0120: An object reference is required to access non-static member `UnityEngine.ConstantForce.relativeForce’

Assets/myUnderwater.cs(90,63): error CS0119: Expression denotes a type', where a variable’, value' or method group’ was expected

Thanks for any help.

First - constantForce should start with small case letter as in example here: Unity - Scripting API: ConstantForce.relativeForce. Second - you forger new operator.

constantForce.relativeForce = new Vector3(0,-200,0);

The first error is because you’ve capitalised the first ‘C’ by mistake, and are therefore referencing the static system class ConstantForce instead of the public accessor for a ConstantForce instance. Try constantForce.relativeForce instead.

Second error is because you need to “new” up a new Vector3 instance to assign.

So you’re fixed code would be:
constantForce.relativeForce = new Vector3(0,-200,0);