Search code examples
actionscript-33daway3d

Away3D (4.x broomstick) How do you convert global to local position of an object?


I am building a game that launches a ball at a target(Plane). The Plane is rotated back 45 degrees. I want to convert the global ball position(x,y,z) into the local coords of the target so I can detect where it hits.

Any ideas?


Solution

  • Use the target plane's inverseSceneTransform to transform the position vector of the ball. That should do it.

    var localPosition : Vector3D;
    localPosition = plane.inverseSceneTransform.transformVector( ball.position );
    

    That should give you the ball's position in the plane's local space.