- Home /
Question by
spacelyjoe · Feb 18, 2014 at 05:18 AM ·
gameobjectrigidbodyforce
Accessing the rigidbody of a certain game object via script?
GameObject go = GameObject.Find("ball");
go.GetComponent<Rigidbody>().AddForce(435345);
also tried
go.rigidbody.AddForce(423423);
neither of them worked how would I do this properly?
Comment
Answer by whydoidoit · Feb 18, 2014 at 05:24 AM
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));
Your answer
Follow this Question
Related Questions
Game objects sliding when frozen z-axis? 0 Answers
Get force applied on a gameobject 2 Answers
Check if object is applying force to another object 0 Answers
Recoil on self-object 1 Answer
Unexpected Force being applied after adding rigidbody 1 Answer