• Home
  • About us
  • Articles and Tips
  • Contact us

Articles

Home / Articles / Real-world testing and Improving spherical obstacle avoidance

Real-world testing and Improving spherical obstacle avoidance

Posted on: 07-13-2010 Posted in: AI, Unity, UnitySteer

Over the weekend I pushed some UnitySteer changes to the development branch on Github. Some of these came about as a result of testing in unexpected conditions, so I thought a write-up might be interesting.

I was looking for some simple prototyping models, to give a better visual idea than with the cubes. Matt from M2H kindly shared some funny looking figures from their Vikings and Bankers prototype, which I promptly added.

They had a characteristic I hadn’t expected: after exporting them from Blender to Unity, the pivot point ended up at the base of the figure. This meant that the vehicle was off-center, as can be appreciated on the grey outline here:

Us Center

After some hemming and hawing, I ended up adding a Center property to the Vehicle class. It behaves much like the center on a SphereCollider, and is affected by the parent transform’s scale. For consistency, I extended the same behavior to the vehicle radius.

Testing this pivot point issue brought to my attention some issues from OpenSteer’s implementation of the method for finding an intersection between a line and a sphere. This is how a box is perceived as a SphericalObstacle:

Us Box Perception

In many cases on this test scene, the OpenSteer implementation just didn’t detect any collisions with the circle. Looking into the Paul Bourke derivation referenced on the code, there were some implementation decisions that didn’t make sense to me – for instance, the future vehicle position seemed to be used only for calculating the distance after the intersection point has been estimated, but not for estimating the line endpoint itself. I ended up re-writing FindNextIntersectionWithSphere and updating the method for steering away from a spherical obstacle.

There was a bit of a funny overcompensating bug, in a case where the implementation still detected an intersection when the obstacle was already behind it:


But I’ve fixed it and avoidance now behaves as expected:


We now have much smoother behavior, even when navigating multiple obstacles (cyan circles are the vehicle’s perception radius, the cyan lines their intended path when they detect an obstacle, the red and magenta lines trace vehicles and obstacles they’re steering away from):


Funny how something as simple as looking at a model that is a bit different from your tests can lead you to improvements you hadn’t initially planned.

Of course this still follows what Mikko referred to in his Paris talk as the sumo approach, as it is still following a similar line of thought to the one used in UnitySteer. The good thing is that ever since the reorganization, replacing this with an velocity obstacle-based approach would be straightforward, so it’s something that might be in the cards in the near future.

About the Author

Ricardo J. Méndez

  • Popular Posts
  • Related Posts
  • UnitySteer 2.1 released
    UnitySteer 2.1 released
  • UnitySteer: How are you using it?
    UnitySteer: How are you using it?
  • Postmortem: The whole indie gamedev thing
    Postmortem: The whole indie gamedev thing
  • UnitySteer: Experimental vehicle and radar changes
    UnitySteer: Experimental vehicle and radar changes
  • UnitySteer: Experimental vehicle and radar changes
    UnitySteer: Experimental vehicle and radar changes
  • Updates for March 7-14, 2011
    Updates for March 7-14, 2011
  • UnitySteer: the next few months
    UnitySteer: the next few months
  • UnitySteer 2.1 released
    UnitySteer 2.1 released

Leave a Reply

Click here to cancel reply.

Recent posts

  • Public Alpha 2
  • Project K – Polish and Effects
  • Changes from Alpha 1
  • Screenshot Saturday 20120114
  • Project K – Playable Alpha

Recent comments

  • UnitySteer 2.1 released « Arges Systems on UnitySteer 2.2 released
  • UnitySteer – Steering components for Unity « Arges Systems on Project K – Playable Alpha
  • UnitySteer – Steering components for Unity « Arges Systems on UnitySteer 2.0 – multiple agents example
  • Ricardo J. Méndez on UnitySteer – Steering components for Unity
  • Isaac R. on UnitySteer – Steering components for Unity
© 2009-11 Arges Systems Inc.. All Rights Reserved
TwitterStumbleUponRedditDiggdel.icio.usFacebookLinkedIn