Skip to content

Get MotionProperties with bodyInterface #1130

Answered by jrouwe
kozakromch asked this question in Q&A
Discussion options

You must be logged in to vote

The BodyInterface provides a lot of convenience functions to quickly set properties. I did not expose everything (mainly because I was lazy). To set these properties you would do something like:

BodyLockWrite lock(*physics_system->GetBodyLockInterface(), body_id);
if (lock.Succeeded())
{
	MotionProperties *mp = lock.GetBody().GetMotionProperties();
	mp->SetLinearDamping(linear_damping);
	mp->SetAngularDamping(angular_damping);
}

B.t.w. if you have a Body * then you can also set these properties directly, just make sure that it is not done while something else is reading the values (Jolt itself only reads this during very specific times in PhysicsSystem::Update).

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by kozakromch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants