Page 1 of 1

Have surface velocity affect only one body in a collision?

PostPosted: Wed Dec 18, 2013 6:51 pm
by Exploding Rabbit
I'm using surface velocity to move my player around. This works great on kinematic bodies because the player can move across the other body without affecting it. However, if the player is walking across a nonkinematic body, the player moves correctly, but the other body moves in the opposite direction because it is also being affected by the surface velocity. I understand that I can modify the relative surface velocity of the collision by modifying the arbiter, but that changes it for both bodies.

Basically, I am wondering if it is possible for the surface velocity to only affect one of the bodies in a collision, and for the other object to ignore the surface velocity when calculating its collision response. If this is not possible, is there anything you'd recommend as a workaround?

Re: Have surface velocity affect only one body in a collisio

PostPosted: Thu Dec 19, 2013 11:30 am
by slembcke
Unfortunately no. Surface velocity works by causing friction forces to happen between the two objects and you can't restrict it to apply to only one of the bodies. This is correct physical behavior, just not quite what you want in this case I guess.

There are a few things you can do to reduce the effect. Making the player lighter or the object object heavier. Gradually increasing the surface velocity helps too if the problem is things tend to "pop" when you are standing on them and start the character moving. If adjusted and tweaked correctly, it can make the interaction seem really natural and look really nice.

If you really want the interaction to be one way, then you'll need to set the shape (or just the collision) to be frictionless and use forces or (careful) velocity adjustments to control the player when they are standing on that surface. There really isn't any way within the solver to make a unidirectional force.

Re: Have surface velocity affect only one body in a collisio

PostPosted: Sat Dec 21, 2013 1:40 am
by Exploding Rabbit
The solution that I wanted to do was to apply an impulse to the other body opposite of the impulse that is generated by the surface velocity. However, if I apply an impulse to a body in the Presolve method, it doesn't take effect until the next physics step, so the body would be in the wrong place for one frame. Is there any way around that? Is it possible to add or subtract from the impulse that resolves the collision?

Also, do you know how I'd calculate the impulse generated from the surface velocity so that I can cancel it out, or is this the wrong approach?