3
\$\begingroup\$

I have a bunch of fighter AIs that are doing attack runs on a target (Currently just a cylinder).

It is designed to veer off course the moment it gets too close and loop around for another attack run. Using a raycast, I raycast ahead 5 units and do obstacle avoidance.

Using a sphere/capsule collider for the cylinder, I get good results. The fighters veer off course and doesnt collide with the cylinder.

enter image description here

However, the moment I switch over to a mesh collider, they start veering off course late. Moreover, there is also a delay before the ships realise that they are within weapons range. (Also a raycast)

Each of the white gizmos are a collision point detected by a trigger collider enter image description here

\$\endgroup\$
  • \$\begingroup\$ I notice you're using 3D colliders but the screenshots you show are 2D, looking straight along the y axis. Both sphere and capsule colliders will add some y thickness beyond a thin disc used by a mesh collider — is it possible your rays are missing in the y direction, or skipping near-parallel to the flat face of the cylinder? What does your debug drawing look like from a 3/4 view? \$\endgroup\$ – DMGregory Jun 13 '16 at 19:19
  • \$\begingroup\$ @DMGregory My bad. It was working when I had a much further approach distance but in an attempt to make the movement more sporadic, I closed in the approach distance and my correction algorithim didnt have time to reposition the fighters. \$\endgroup\$ – DarkDestry Jun 13 '16 at 20:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.