There might be an error in the sample code for CapsuleCast

Hello, I want to preface this by saying that I’m no expert and this might be completely wrong. Just thought I’d check if this is just me or if there is a mistake.

The sample code for Capsule Casting shows how to get the points where the capsule should start and end, while this is fine to visualise the full length of the capsule cast by using Debug.Drawline it doesn’t work for the actual capsule casting.

Basically this is what the code is telling people to do

While it should be like this

However, in the description, Capsule Casting is described with:

Which is not what the example reflects

Again, I could be massively wrong, but I was having problems with capsule casting and this was the exact reason why. I would be very grateful if someone with more experience than me could look into this and either confirm it or deny it.

Thank you

I’ve added a bug into the fogbugz system. Am sure it’ll get looked at soon.

Have had a few minutes looking at this… and I am 99% sure that p1 and p2 mark the visual top and bottom of the capsule. Your top right diagram is correct in my quick look. In the docs point1 and point2 refer to the start and end [of the capsule].

(I needed transform.forward to be transform.up in my simple copying of the script.)

I will try another quick test later… maybe it doesn’t matter where the spheres are…

So, had another test… and am 100% sure it doesn’t actually matter if you make a capsule cast from the top or P2 in your description. I’ve got a trivial test which shows a capsule and a cube above it. You can fire a ray from the top or internal position. Both will hit the cube. (Out of the box, so to speak, the cube is high enough for the internal P1 to not hit it.) Thoughts?