Objects move a fraction of the way through controller collider every time
Hello. I'm relatively new to Unity and very new to these forums. Advanced apologies for any trouble or headache this newness causes.
I have a simple script attached to a cube with a rigidbody, trigger and box collider that sucks the cube toward the player using AddForce when the player is inside the trigger and presses a key:
if(Input.GetButton("Pull")) {
rigidbody.AddForce(direction * 30);
Debug.Log("Pull");
}
The script works great, but when the cube collides with the player the block stops hard as if it's hitting the collider, except 1/5 of the way through the collider instead of on the edge. This causes the block to spaz out and push away from the character once the character moves forward. The collider works fine if the player moves to the block, but not the other way around. The player and the block both have rigidbodies. The player's rigidbody is kinematic. I've tried ignoring physics layers. I've tried changing "max penetration for penalty" to a low number. I've tested in both Update and FixedUpdate. I've tried altering the skin width on the character controller. I've tried using different combinations of "continuous" and "continuous dynamic" collision detection. It strangely doesn't appear to be a problem with velocity, since it even happens when the block is traveling extremely slow. Even if I change the size of the collider, it's always exactly the same. The block always stops 1/5 in.
Additionally, when this happens, if the player is occupying both the cube's trigger as well as the trigger from another object, both triggers will behave as though they are one single trigger. In other words, even if I exit the other object's trigger, the functionality of that trigger doesn't seize until I exit both that trigger as well as the cube's trigger. This trigger confusion only happens when the player pulls the cube in to the 1/5 collider overlap.
Upon further investigation, i've found this happens with any moving object, whether pulled by the AddForce script or not. So I can't be sure, but I don't believe it has anything to do with the script. It seems to me that, in my amateur status, there is some basic functionality of character controller colliders that I am not understanding.
I tweaked the script to determine the distance between the block and the player and to stop before the block penetrates the collider, but that's more attacking the symptoms rather than the cause, and doesn't quite work with the gameplay I'm going for.
I'm running Unity 4.6.3
Any help or insight would be greatly appreciated.
EDIT: TLDR version: Objects moving toward a character controller collider pass through the collider and make contact at an invisible point inside the collider, but a character controller collider that runs into static objects stops right at the collider bounds. Can someone explain this to me? It seems I need to wrap my head around passive vs active collision detection, but I'm having some trouble understanding what is happening here and I can't seem to find what I'm looking for in the documentation or forums. Thank you.
Your answer
![](https://koobas.hobune.stream/wayback/20220612075832im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Character controller walk over other moving collider 0 Answers
Character moves up from plane due to character controller radius and hight. 0 Answers
character feet go slightly beneath floor in certain situations 0 Answers
Trouble with collison and trigger's 1 Answer
Help with getting my player to stop moving when they hit a wall? 0 Answers