Have surface velocity affect only one body in a collision?

Chipmunk2D Bindings for the Unity3D engine

Have surface velocity affect only one body in a collision?

Postby Exploding Rabbit » Wed Dec 18, 2013 6:51 pm

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?
Exploding Rabbit
 
Posts: 14
Joined: Wed Dec 04, 2013 3:31 am

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

Postby slembcke » Thu Dec 19, 2013 11:30 am

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.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

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

Postby Exploding Rabbit » Sat Dec 21, 2013 1:40 am

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?
Exploding Rabbit
 
Posts: 14
Joined: Wed Dec 04, 2013 3:31 am


Return to Chipmunk2D for Unity

Who is online

Users browsing this forum: No registered users and 1 guest

cron