Disabling contant force?

private var conForce : ConstantForce;

function Start () 
{
        conForce = GetComponent(ConstantForce).enabled = false;
}

Not really sure how to disable the constant force component, if there is a concrete way.

Thanks.

It is the double equals that is messing you up. Use:

GetComponent(ConstantForce).enabled = false;

Note that there is short cut variable as part of GameObject you can use instead:

constantForce.enabled = false;

Unity does a GetComponent() under the hood, so it doesn’t save the call, but it makes code a bit cleaner.

Just so you know, turning off constant force will not stop your object from moving unless you have the drag turned way up.

#pragma strict

var cForce : ConstantForce;

function Start()
{
    if(GetComponent(ConstantForce))
        cForce = GetComponent(ConstantForce);
    if(cForce != null)
        cForce.enabled = false;
}