O'Reilly logo

Away3D 3.6 Cookbook by Michael Ivanov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Detecting whether an object is in front of or behind the camera

Now let's see how we can check whether a certain object is located in front of or behind the camera. Such a check may be useful if you develop an FPS game where you need an enemy agent or any other non player character (NPC) to be able to detect whether other agents are behind or in front of it. Fortunately, this task is easy to accomplish. Linear math has a calculation called dot or inner product. The Dot product is a sum of products between corresponding components of vectors that should lie in the same plane. Also if one of the vectors is zero, the Dot product would be zero as well. In Away3D, you don't need to deal with that math directly. Vector3D class has got already built-in ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required