Unity3D addForce or ConstantForce problem

I am really not understanding wats going on here but i need help in this code. I am trying to simply add ConstatForce to my object with RigidBody component applied and i am not getting any results. Below in my code can u also tell me why each of the lines aren’t working.

function Update () {

constantForce.force.x = 10;

rigidbody.AddForce(0, 10, 0);

GetComponent(Component).constantForce.force.y = 5;

transform.rigidbody.AddForce(transform.forward * 30);
}

even this doesnt seem to work…can u provide an explanation?

this.constantForce.relativeForce = Vector3(100, 0, 1)

function Update ()
{
rigidbody.AddForce(Vector3(0,10,0));
}

This works perfectly, and it not then you are doing something wrong.

Can u confirm if the rest of the above lines work?

rigidbody.AddForce(Vector3(0,10,0)); works but not constant force.

ok Step 1: i created cube
Step 2: i added rigidbody component from component tab
Step 3: i wrote that script

ok i c the problem but i dont know how to solve it

function Update () {

var direction_z = target_point.position.z - transform.z;

rigidbody.AddForce(100, 100, 0);

}

upon runnin above code i get following error

NullReferenceException: Object reference not set to an instance of an object
Boo.Lang.Runtime.RuntimeServices.InvokeBinaryOperator (System.String operatorName, System.Object lhs, System.Object rhs)
magnet.Update () (at Assets/Standard Assets/NEX ASSETS/magnet.js:9)

What is the point of: var direction_z = target_point.position.z - transform.z; ?

Also, you should differentiate between constant force and constant velocity. If something has a constant force then it will behave in a realistic matter, where something at rest (the cube is at rest when you start the game) will gain the velocity over time. If you want something to be moving in a direction at constant speed without this type of behavior then you have to override the physics simulation by making the object kinematic and moving its rigidbody “by hand”, for example as such:

rigidbody.position += Vector3(0,10,0).Normalize() * speed * Time.deltaTime; (note; not tested)

You could of course keep the object non-kinematic and sets the velocity directly by just setting the rigidbody.velocity = Vector3(0,10,0); but that is bad practice as the velocity should never be manipulated directly (although I personally have never had any problems with setting it to 0,0,0).