- Home /
Controll squeeze of rigidbody between static collider and kinematic rigidbody.
Hi. Is there a way to detect and controll if a rigidbody is beeing squeeze between a static collider and a kinematic rigidbody?
This is my setup: I got a nonkinematic rigidbody as player. It lives inside of a box of static colliders. Those are the absolute boundaries in which the player is allowed to move. Furthermore I got kinematic boxes moving with rigidbody.MovePosition. They are able to push the player arround which is intended. However if the player gets stuck between the moving box and the boundary, he will be pushed throug the static collider and leave the allowed area.
How can I detect if this is happening or how can I tell the player to be pushed through the moving box rather than the static collider? Is there an easy way to do this or do I have to force him by script (would be harder to handle than simply setting colliders)? Thanks in advance.
Answer by xikky · Feb 21, 2013 at 07:07 PM
If i'm understanding you well, you might need to use the following script which can be found here.
This script is used to stop objects going through other objects (generally due to large forces created).
In your case, attach the script to your character. Add a new layer and you can name it anything, such as 'Boundary'. All objects making the boundary put them in this layer. In you character inspector find you script and select the layer 'Boundary'.
First of all: Thank you for your answer. This is probably not your fault, but the script is incredibly bad. It is redundant, framerate dependant, only triggers if you move at a very high speed which depends on the size of the collider, can't handle colliders wich equal extends in all directions and causes massive jittering when it takes effect. And I'm not even talking about what is happening when you try to walk diagonally into the wall or worse into a corner.
Aside from that, I'm not looking for a script. I wanted to know if there is a way to let PhysiX know how it should handle the conflict on its own. $$anonymous$$y particular problem serves more as an example for the general question, but thanks for the effort.
Yes I know, but this is the only method to stop collisions at high speed that I know of, and it works. It is true that it does cause jittering (only when the speed is really high) but I normally try to find work arounds so not to show the jittering.
The speed is not really the problem. The collision conflict which happens when the character gets squeezed between two colliders is. Writing a script which forces the character inside of the given bounds shouldn't be a problem for me either. I simply wanted to know if I can let PhysiX handle the conflict on its own in a controlled manner.