PhysX Source Code for UE4 Question

Hi everyone. I only know the basics of programming - and I am NOT a super cool programmer of the 80th level. So do not rush at me with advice that I need to learn everything from A to Z. I am doing a project and learning in the process. But the problem that I encountered is not solved by the standard editor tools, and writing “my own” physics from scratch will probably be much more difficult than making edits to an already written physics engine.

I recently learned that there is access to the source code of the physics engine. I need that when two or more objects collide (collide only), no angular impulse is generated, or a zero angular impulse is generated so that the objects do not start rotating when collide.

I could use constraints, or just set the angular velocity to zero during a collision, but I need objects to be able to rotate when forces are applied to them, but not generate angular impulse when colliding AT THE SAME TIME. In several other communities, I was told that it was impossible to do this using the engine’s standard tools.

Can anyone explain me, how can i do this?

The people in the other communities are right. If external forces are able to rotate objects but the code keeping them from interpenetrating is not allowed to rotate them, then there will be situations where it will not be able to do its job and keep objects from interpenetrating.

Maybe then there is a way to write a very simplified version of the collider directly in UE? A collider that would simply linearly block objects from passing through each other. This would be very difficult to implement and is it even possible?
It’s just that it seems to me to write my physics from scratch is very difficult and time-consuming. Is there really no way to get the result I want without rewriting tons of code from scratch?

If contact modification is enabled on the collision, you can modify the invMass and invInertia scales on the contact. There are scales for each colliding body. These scales are defaulted to 1, but setting the invInertiaScale to a value less than 1 makes the inertia larger, while setting invInertiaScale to a vale > 1 makes the inertia smaller. The larger the inertia, the les the body’s angular velocity will change as a result of collision. If you set invInertiaScale to 0, the contact will not be able to change the body’s angular velocity at all.

As Adam said, if the body is rotating, but the contact solver is not allowed to apply torques to counteract the rotation, then it may not be able to correctly resolve the collision, so your mileage may vary if you use this feature. It’s been used successfully in a number of games - mostly driving games - to tune contact behavior to make objects rotate less on collision.

Oh my God, I no longer hoped that there would be a solution to the problem. This is the last problem I faced in implementing the mechanics of my game. It would be really great if you could give me a little more information on how to do this. As I said, I’m not a cool programmer. I only know the basics. And the fact that I can edit the source code, I also learned quite recently. To be honest, I am not at all familiar with the internals of the physics engine. If this is not very difficult, could you please describe the process in more detail?

This is just my case. I am doing a remake of an one old game (racing / shooting simulator). In this game, collisions do not generate any angular momentum at all. I think this is what I need)

Unfortunately, I’m not all that familiar with UE4 and how it exposes contact modification. However, I did find that the class you’re probably looking for, but it’s probably going to end up requiring reading quite a bit of the UE4 guide/following some online examples (if you can find them) to figure out what you are supposed to do:

ContactModifyCallbackFactory | Unreal Engine Documentation

I can explain what you need to do from the PhysX perspective quite easily, though. It’s explained in the guide here:

https://docs.nvidia.com/gameworks/content/gameworkslibrary/physx/guide/Manual/AdvancedCollisionDetection.html#contact-modification

And doxy for the specific class you’ll be modifying is here:

https://docs.nvidia.com/gameworks/content/gameworkslibrary/physx/apireference/files/classPxContactSet.html

The method to adjust the invInertiaScales are setInvInertiaScale0 and setInvInertiaScale1.

Yes, there are some difficulties in this. There is practically no training material on PhysX. Only the documentation, but it is not written for beginners. But, thank you so much for at least pointing out which direction to dig)
Apparently, this can be done directly from the game engine. Well, without having to build the engine from source. It’s just great. I will try to understand. Thank you very much for the help :)