- Home /
Does Sweeptest actually work?
Hi all,
I'm trying to do something real simple or so I thought. I wish to control the movement of a cube (box collider) so that it moves kinematically but stops when it collides with a mesh. I use sweeptest to check 'ahead' but either the object intercepts before the collision occurs or a collision is registered when they aren't colliding. The 'range' parameter seems a bit of a magic number. Any info and what is needed or how sweeptest works internally would be great.
Cheers
Answer by billunitydev · Feb 13, 2014 at 08:34 PM
I have struggled with the box/cube collider sweeptest for about 8 hours now.
I was getting what appeared to be "false positives" against a mesh collider (i.e. hits/collisions when I was not expecting them).
After about 3 hours of examination, I hypothesized that the box/cube sweeptest might be using the AABB (i.e. collider.bounds) for the sweep. However, after another 3 hours I disproved my hypothesis. After another 2 hours I just gave up trying to figure out what on earth the box/cube sweeptest was trying to do because I was out of ideas. Would love it if someone could actually describe the behavior accurately (and not just quote the unity reference because it's flat out wrong for boxes/cubes).
Instead I switched to a bunch of capsule sweeptests that would give me the same coverage and the results so far look good. Depending on the shape you are trying to sweep, a bunch of raycasts might be more appropriate.
-b
Your answer
Follow this Question
Related Questions
Sweep for vertex positions? 1 Answer
Any way to prevent sweeptest from colliding their triggers? 1 Answer
Rigidbody.SweepTest - Local or Global axis? 1 Answer
Why some types of colliders2D can't be hit be sweeps? 0 Answers
Moving and SweepTesting a kinematic Rigidbody multiple times within a single FixedUpdate() call 0 Answers