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?
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?
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.
Above solution only works if the item/ball is directly on the stage. If it isnt, you should use ball.scenePosition!
item.position = targetContainer.inverseSceneTransform.transformVector(item.scenePosition);