Hi, It's been literally 5 full days that im working with my character collision code using CapsuleCast, and everytime i switch between the 2 codes below, i get a totally different behavior. Code (csharp): if (Physics.CapsuleCast(new Vector3(g_position.x, g_position.y + 0.0f, g_position.z), new Vector3(g_position.x, g_position.y + 2.0f, g_position.z), 0.5f, new Vector3(0, fDist, 0).normalized, out rayHit, Mathf.Infinity)) Code (csharp): if (Physics.CapsuleCast(new Vector3(g_position.x, g_position.y + 2.0f, g_position.z), new Vector3(g_position.x, g_position.y + 0.0f, g_position.z), 0.5f, new Vector3(0, fDist, 0).normalized, out rayHit, Mathf.Infinity)) Notice the p1 and p2 parameters. The 2 codes should behave and return the samething, but they dont. The first works perfect for me while the second return weird values. Why?
Oh, I found the exact same behaviour a while ago! It seems that the first argument must be the bottom of the capsule and the second the top, otherwise it's all wrong. I wonder if it's something to do with the way it's 'drawn out', maybe the normals of the capsule become inverted or something? I don't know but it's definitely weird Also is there a reason why you have a + 0.0f ? You might as well just write g_position.y
Thank you so much. This has helped me tremendously. Usually I add before I subtract and do actions from top to bottom, so I actually spent two days trying the same thing over and over again (always noticing that only SphereCast worked, but never CapsuleCast). I was under the impression this was a driver problem with Nvidia's Physics for my laptop, since my laptop is often buggy as far as my 555M graphics card goes. The two days weren't really spent in vain, though, because I actually optimized my spherecast to be able to run without a reduced radius (because if the cast starts out inside of an object, SphereCast/CapsuleCast is not called) by buffering the player away from the wall's position and the floor's position. This made my day!
Thanks RoxCoder and Aniani, I would have been messing with this for days. Nearly 2 years since the original post and this important note still isn't in the docs.