Set cursor to center of mass of selected bodies

Let us know if you have a nice R.U.B.E script to share!
Post Reply
iforce2d
Site Admin
Posts: 860
Joined: Sat Dec 22, 2012 7:20 pm

Set cursor to center of mass of selected bodies

Post by iforce2d » Wed Apr 03, 2013 7:37 pm

Code: Select all

body[] bs = sb();

vec2 c = mv(0,0);
for (uint i= 0; i < bs.length; i++) 
	c += bs[i].getWorldCenter();

float n = bs.length; //this needs to be a float type
setCursor( 1/n *  c );

Post Reply