method to determine if an object is set to dynamic

Bool RigidBodyComponent.IsDynamic

built in rounding of vectors and quaternions for display purposes

Vector somevector;

somevector.Round(2);

Vector RoundVector(Vector what, int decimals)
{
return new Vector(
(float)Math.Round(what.X, decimals),
(float)Math.Round(what.Y, decimals),
(float)Math.Round(what.Z, decimals),
(float)Math.Round(what.W, decimals)
);
}//RoundVector

Quaternion RoundQuaternion(Quaternion what, int decimals)
{
return new Quaternion(
(float)Math.Round(what.X, decimals),
(float)Math.Round(what.Y, decimals),
(float)Math.Round(what.Z, decimals),
(float)Math.Round(what.W, decimals)
);
}//RoundQuaternion

#### 10 comments

• Galen

That's what Vector.ToString() is for. You can pass in a format argument.

• Galen

Right now, the easiest way to determine if an object is dynamic is if there is a RigidBodyComponent available in the object.

• OldVamp

string format doesn't seem as nice

-12.000600006f
.ToString("f2")
-12.00
Math.Round()
-12

Just having a physics volume doesn't mean 'is dynamic' is set

• Lex
Edited by Lex
• Galen

Yes, but you won't get a rigid body from a static object, despite it having a physics volume. You'll only get one if it's marked as dynamic.

There are some oddball cases where an object is dynamic but you don't see it as obviously such. Tyler recently discovered that a trigger volume, for example, can be moved using RigidBodyComponent.SetPosition() and .SetOrientation(). Curiously, though, it doesn't fall under gravity the way other dynamic objects do (by default).

But the short answer is: yes, if you can get get a rigid body for the object, you can presume it is dynamic. For now, at least.

• OldVamp

try it out, tell me your results

• Galen

Try what out? This technique is what most of my scripts use already.

• Gindipple

Just use Vector.ToString("0.00") if you want to trim up the display

• OldVamp

test if an object with a collision volume has a rigid body when it is not set to dynamic.

• Galen

I get annoyed when people give me little brain teaser challenges instead of just showing what they have discovered with their own testing.

Okay, so to your point, I just discovered you are correct.I ran this test (after a little delay):

`RigidBodyComponent Body = null;ObjectPrivate.TryGetFirstComponent(out Body);ScenePrivate.Chat.MessageAllUsers("Rigid body: " + (Body != null));`

Sure enough, it reports that a static object has a rigid body. You could have just said that.

So, yeah. This is not a reliable way to determine if an object is dynamic. My mistake.

Please sign in to leave a comment.