Game Development Community

T2D Physics issue

by Chris Labombard · in Torque Game Builder · 03/19/2006 (10:01 am) · 1 replies

I am having some physics troubles. I am creating some balls and they are in a container. They are acting very strange.

Firstly, the balls sit in the bottom of the container and act properly, but once I have about 4 rows of balls, the balls start getting pushed out of the container and popout.

Also, the balls vibrate really badly like they're colliding back and forth very fast. If I alt-tab out of the game and then back, the simulation has gone nuts and the balls have stopped being at rest and are vibrating really bad.

This is how Im creating the balls.
$planet[$numPlanets] = new t2dStaticSprite() { scenegraph = t2dscene; };
    $planet[$numPlanets].setImageMap(planetTestImageMap);
	$planet[$numPlanets].setSize("5 5");
	$planet[$numPlanets].setCollisionActive(true, true);
	$planet[$numPlanets].setCollisionPhysics(true, true);
	$planet[$numPlanets].setCollisionResponse(RIGID);
	$planet[$numPlanets].setCollisionCallback(true);
	$planet[$numPlanets].setCollisionPolyPrimitive(8);
	$planet[$numPlanets].setCollisionMaxIterations(2);
	$planet[$numPlanets].setLayer($planetLayer);
	$planet[$numPlanets].setGraphGroup($planetGroup);
	$planet[$numPlanets].setCollisionMasks(BITS($wallGroup SPC $planetGroup SPC $mouseGroup), BITS($wallLayer SPC $planetLayer SPC $mouseLayer));
	$planet[$numPlanets].setMaxLinearVelocity(250);
	$planet[$numPlanets].setConstantForce(0,50,true);
	$planet[$numPlanets].setRestitution(0.5);
	$planet[$numPlanets].setDamping(0.1);
	$planet[$numPlanets].setFriction(0.01);
	//$planet[$numPlanets].setMass(5);
	$planet[$numPlanets].setPosition(-20, -25);
	$planet[$numPlanets].setAutoMassInertia(true);
	$planet[$numPlanets].setLinearVelocity(15, -15);

and this is how Im creating the walls of the container.
$topWall = new t2dStaticSprite() { scenegraph = t2dscene; };
    $topWall.setImageMap(bottomWallImageMap);
	$topWall.setCollisionActive(false, true); // send but dont receive?
	$topWall.setCollisionResponse(CLAMP);
	$topWall.setCollisionPolyCustom(4, "-1 -1","1 -1","1 1","-1 1");
	$topWall.setGraphGroup($wallGroup);
	$topWall.setLayer($wallLayer);
	$topWall.setRotation(90);
	$topWall.setSize("2 50");
	$topWall.setPosition("0 -36.5");
	$topWall.setImmovable(true);

Has anyone else experienced the same thing? How do I stop it from acting like this?

About the author

I have been a professional game programmer for over 5 years now. I've worked on virtually every platform, dozens of games and released a few of my own games, including 2 iPhone titles and a title waiting release on Big Fish Games.