Game Development Community

Mass and drag

by Josiah Reeves · in Torque 2D Beginner · 02/11/2014 (2:56 am) · 3 replies

Hello, It's been a very long time since I've used Torque and I've been looking for a while now for a way to change an objects mass and or drag. I'm guessing it's fairly simple so if someone knows it would be really appreciated. Thank you!

#1
02/11/2014 (4:33 am)
You cannot change the mass directly. Remember, mass is volume multiplied by density. You want to manipulate the density, size, and default friction:

// Create a sprite with values
%sprite = new Sprite()
{
   DefaultFriction = 1.0;
   DefaultDensity = 1.0;
   Size = "10";
};

// Alternative method
%otherSprite = new sprite();
%otherSprite.setDefaultDensity(1.0);
%otherSprite.setDefaultFriction(1.0:
%otherSprite.size = "10";
#2
02/11/2014 (10:42 pm)
Thank you! I can definitely see a difference in the way that other objects can or cant move that object but the speed at which the object falls in free fall seems to never change even when i set the settings really high. Would i just have to change the gravity or is there some other way to do that. Also is there a way to change an objects center of gravity?
#3
02/12/2014 (12:51 am)
Gravity affects all dynamic bodies in the Scene equally. If you want to change how gravity affects individual bodies, look at the GravityScale property.

I'd also recommend reading the Physics Guide for more info.