# One sided collision detection???

Hello,
I’ve noticed that when I use “rigidbody.MovePosition” in order to move my customly made character that I’ve specially designed to easily interact with 3D physics (like in a rigid body character controller), that if I use enough speed in my MovePosition function in such a way where my character passes through a collider as opposed to hitting a collider, the whole collider gets ignored. Is there any way to use the rigidbody.MovePosition function where if my character hits a collider OR passes through a collider, to behave like it would if it only hit a collider by not ignoring the collider that it passes through?

I know to use Physics.Raycast in addition to rigidbody.MovePosition, but the problem with that is I don’t want the character to stop completely if it hits or passes a collider, and don’t know what to put in my if statement IF the raycast hits or passes through a collider (which Physics.Raycast doesn’t ignore raycasts that passes through colliders, stopping the character from going through a wall if it moves too fast). rigidbody.MovePosition doesn’t stop the object completely if the object hits a collider but has the object brush up against the other object that it hits instead (which I want my character to do when it touches a wall). This is why I use rigidbody.MovePosition for my physics calculations instead of Physics.Raycast since rigidbody.MovePosition does what I want my character to do when it hits a wall, but I also want the function to detect when the rigidbody that it uses passes through a collider too. How would I do that?

Also, what do you think of the idea of adding an extra property in RaycastHit that determines if the ray is inside or has passed a collider?

Thank you,
Michael S. Lowe

Set the physics type for that object to Continuous or up the solver count then it will not pass through.

All mesh colliders are one-sided just so you know, the side the normals point out at.

You can use the collision commands to detect what you are colliding with.

There’s Enter (this is deceptive: it only means when it first touches something), Stay (this is for constantly touching something) and Exit (for when it stops touching something).

I set my game character’s rigidbody to continuous and still, I see the rigidbody walking through colliders.

I made the capsule collider fatter and it works better now with no rigidbody going through any colliders, but still, why should my character have to be fat in order to not walk through objects? I also theorize that if I add more shapes to my game and it reduces the amount of frames per second that it takes to render, but causes my character to appear to move virtually at the same speed, my character is actually moving faster, so in the future, I’d have to make my character even more fatter to cover more territory. Therefore, I think continuous works but in a different way, and still works as long as the rigidbody does not pass completely through a collider and out through the other side. They should invent an option like I suggested that appears to collide even when the rigidbody passes through a collider.

Use Continuous Dynamic

It has to be fat because you haven’t changed your physics settings. Probably the world scales are all off too.

I’ve tried continuous dynamic and the same thing still happens. The colliders behave more like water as I see that there is some kind of continual calculation going on as long as there is some kind of bonding interaction between the rigidbody and the collider, and as soon as the rigidbody is on the other side of the collider (past the center), the collider seems to push the rigidbody on through to the other side actually, and if the rigidbody is not yet on the other side of the collider, the collider then pushes the rigidbody away from the collider. It behaves like a magnet pushing another magnet away from the center. What I am trying to do is prevent the rigidbody from making it to the other side of the collider and not even to the center, not even inside the collider.

I have an empty object called “Player” set at scale 1, 1, 1 and a child object camera named “Camera” at scale 1,1,1, so everything is at scale 1,1,1 and Camera is set to position 0,0,0, so no scales are off.

Are you:

a) changing the physics settings? this means going to project settings->physics, and understanding the Solver Iteration Count? Thats something I keep mentioning and you keep ignoring. It shouldn’t be necessary unless you have NOT done the below…

b) you are performing all physics inside FixedUpdate() function. No, you can’t do physics outside that function, because things will pass through other things. Docs explain this but it is often missed by people. Note, physics performed inside fixedupdate should not have their timings adjusted by Time.deltaTime.

Thank you. It seems to work now. I think. I wasn’t using the FixedUpdate() function.

Don’t forget to set interpolate on rigid bodies once you start using fixedupdate, so they move smoothly irrespective of the fixedupdate rate.

I noticed that when I set the interpolate to interpolate, my character bounces up and down.

Perhaps he is happy it works now? …sort of

See if the collider is set too close to the floor. Set it higher above the floor collider and let gravity do the work.
I’ve had a similar problem a few times and moving the character a few units above the ground did the trick.

• Alex