Page 1 of 1

Some damping

Posted: Thu Dec 26, 2013 11:11 am
by mr_join
Hi !
I try to create some damping to the door. Door is - RevoluteJoint + Box with offset,
So, the door is openning by right click + change mouse position :

Code: Select all

float dY = mouseState.Y - Camera.Viewport.Height * 0.5f;
dY = dY * Camera.Speed * dt;
float total = currDoor.GetJointSide() == Vector3.Right ? -dY : dY;
currDoor.ConvexHull.AngularVelocity = new Vector3(0, total, 0);
if (mouseState.RightButton == ButtonState.Released)
   currDoor.ConvexHull.AngularVelocity = Vector3.Zero;
(Not real code, only simple vers).
Soo. And a question is : has a way to reallize damping after some mouse acceleration when the right click release ?

Re: Some damping

Posted: Thu Dec 26, 2013 4:57 pm
by Norbo
The simplest way would be to set the door entity's AngularDamping to a higher value. The value corresponds to what fraction of momentum the entity will lose in one second.

Re: Some damping

Posted: Thu Dec 26, 2013 6:57 pm
by mr_join
i tryed it. if i set angular damping in val = 1f door not move at all.
if val = 0 - damping rarely work; reeeeally rarely;

Re: Some damping

Posted: Thu Dec 26, 2013 7:35 pm
by Norbo
if val = 0 - damping rarely work; reeeeally rarely;
Setting damping to 0 corresponds to not losing any momentum at all (outside of the deactivation system's low velocity stabilization). Values between 0 and 1 are allowed. 0.5 would remove about half the momentum in a second.

Re: Some damping

Posted: Thu Dec 26, 2013 8:20 pm
by mr_join
Thx Norbo. )