How to make objects block each other without being affected by physics interactions
I am writing a custom character controller and encountered a problem with rigidbodies that confuses me. First let me explain what im trying to achieve:
Its a third person multiplayer game (one screen)
- There are basically 4 types of objects:
Player characters (moving)
Enemies (moving)
Objects that can be picked up by the player (they move with the player when picked up)
static objects (world)
Each of those objects should block each other.
There should be no further physics interactions between those objects except some sort of gravity.
So if a player/enemy tries to move against another player/enemy/pickup object he is blocked by that. Same for any other of these combinations. Now it is highly suggested by UT to use rigidbody on any objects that move and have a collider. For me this means the first three kind of objects mentioned above. At first this works well, collisions are detected and there is also gravity. But the problem is that every rigidbody object can push other rigidbodies because of physics interactions. And i do not want this. As far as i undestood you should mark your object kinematic if you do not want them to be influenced by physics but still want those objects treated as non-static colliders. So I marked the enemies as kinematic but this does not help a lot since they still push players and pickups around. So i marked everything kinematic. Now i do not have any collisions at all, there is not even an event triggered. Its like not using rigidbodies at all. It looks like you need dynamic rigidbodies to detect collisions anyway. Dont really undestand why to use kinematic if you want them to be treated as non-static colliders but they wont detect collisions with each other or static colliders anyway. So its useful to use kinematic only in conjunction with dynamic rigidbodies? Is there actually a case you want to be the player or an enemy kinematic at all since they can no longer interact with static colliders?
However. Using constraints instead of kinematic is somewhat half working. The objects wont block each other but they will at least trigger collisions. But they wont be able to move using rb.movePosition. And using transform to move rb objects is also considered a no no.
I really do not know what the default approach is supposed to be in unity for this kind of problem if you are supposed to use RBs for moving objects but dont want them to be influenced by the physics engine except preventing them to move through each other. This does not look like an uncommon case. I mean there a plenty of games that dont have real physics interactions but some kind of colliders that cannot overlap. Lets take a platformer or jump n run as an example if the player character is a kinetic rb he wont be able to detect collisions with static colliders (world). But if it is not kinematic its rotation / position may be influenced by other RBs (enemies) which may be unwanted.
Appreciate any tips and explanations.