Accessing the rigidbody of a certain game object via script?

GameObject go = GameObject.Find(“ball”);
go.GetComponent().AddForce(435345);

also tried

go.rigidbody.AddForce(423423);

neither of them worked how would I do this properly?

1 Answer

1

The GameObject must have a rigidbody attached in the editor and AddForce takes a vector parameter with 3 elements.

someObject.rigidbody.AddForce(new Vector3(1000,0,100));