less impact

Jul 15, 2014 at 3:43 PM
hi again,

I have universal bullet object, that when hit something make damage to it, pushes it back and disappears. Generally it is a good solution, but I have some AI bots, that shoots the same bullet to player and annoying is that the player ship is pushing back with so much force.

So I still need response force after collision, but a little less.

I don't want to changing mass of bullet, because as I've said, impact of hit is good for other bodies. I've tried to change restitution of player body to less than 1.0f but impact effect is the same as if it were equal to 1.0f. When I change it to value greater than 1.0f I can see the effect of higher kickback.

How to reduce the impact response of hit?
Jul 16, 2014 at 2:54 PM
        public static float MixRestitution(float restitution1, float restitution2)
        {
            return restitution1 > restitution2 ? restitution1 : restitution2;
        }
It's the Settings function responsible for this behavior, check if both restitution coefficients are less than 1. You can also change the restitution just for the contact in one of the engine's events.
Jul 17, 2014 at 7:23 AM
Edited Jul 17, 2014 at 7:42 AM
I understand this function, but I don't get when it is calls. When I'am setting restitution I can do it by attribution:

playerBody.restitution = 0.2f;

I don't see any two argumeted function to it. You say that this function is called at each assigned as above? If so, then I understand why restitution is never greater than 1, but how to change it? How do I make that the mininum restitution won't be 1 but less?
Jul 17, 2014 at 9:59 PM
It's called when new contact is created. Check this:
Image
There are a few helpful functions in Visual Studio - find all references, view call hierarchy, or CodeLens indicator showing the calls like above.
Jul 18, 2014 at 8:19 AM
Edited Jul 18, 2014 at 8:32 AM
Ok, thank you, Iv'e found the MixRestitution function, but (sorry) i have one more noob question. How to load my changes in this function to the library and use it in my project?

In my project I have reference to FarseerPhysics XNA.dll, in which probably can't change anything (when I click on the function MixResolution and choose "go to definition" i can see only declaration of this function in Settings [from metadata]. But, I can find the definition in files from downoad like Hello World, and there i can change it. So, how to create a dll with the change entered by me, or how otherwise change the definition of this function?
Jul 23, 2014 at 6:54 AM
I think I'm close to a solution. Finally I've changed the function mixRestitution to this:
        public static float MixRestitution(float restitution1, float restitution2)
        {
            return restitution1;
        }
It seems to me that now I can freely change the restitution. And I change my contact restitution of of bullet and player body. But, I don't really understand how it works at all. To achieve less impact I have to change contact restitution to negative values like - 0.8 to -0.95 (I've more expected positive values from 0 to 1 when 0 is no impact). But the worst is that sometimes the body is minimally retracts back and then continue moving in its direction and it giving the impression of skip frame or momentary game crasch.