- Home /
mass of rigidbody
i have this wall of cubes, like a hundred of them, and their rigidbody mass is all 1. I want to make it all 0.01. Is there a way to do that?
Answer by Kourosh · Apr 29, 2011 at 12:17 PM
Make them all children of an empty game object and attach this script to the parent(empty gamobject).
@script ExecuteInEditMode()
var mass:float; //in inspector change this to 0.01 or whatever you want.
function Update(){ for(var child:Transform in transform){ child.gameObject.rigidbody.mass = mass; } }
the moment you type in a new mass value it should automatically change all.
Whow, thank you VERY much. I've never gotten around to learning how to script for the editor/extending the editor etcetera, but this is so easy and practical I'm sure I'll be using it extremely often! :-)
Scripting your gameObject changes tends to be incredibly useful with large amounts of objects
You dont know how good was your help. Thank you very much.
2 things to remember: remove this script before publishing, and click the check mark to give $$anonymous$$ourosh credit for the answer. :)
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
2D rigidbody movement & walls 2 Answers
Physics not working properly 1 Answer
How would I make an object disappear after a set amount of time? 3 Answers
Static, Non movable rigidbody 4 Answers