Slow WorldToScreenPoint()

Hello. I faced need to use the WorldToScreenPoint() method… 50000 times for frame. Also there is this function gives big load of the processor. Whether there are more optimized ways to define an object position in screen coordinates?

Why would you need to do it 50,000 times per frame???

I want to define thus that the object is covered with other object. For example if the position z of one is farther positions of another and a position x more than a position x of another, but it is less than… I can’t make it in world system of coordinates therefore I need to transfer them to the screen.

Is this a 2D game?

If so your camera shouldn’t have any projection performed on the 2d graphics, in which case the real x positions should be fine enough to set the z depth for them.

If this is a 3d game, are you saying that the x position of the object increases it’s position in the z? I’m not exactly sure what you’re attempting to accomplish if this is 3d… would be odd.

I need to define, whether the object is closed by other object. Using system of coordinates of the camera I do it so:

Transform obj1;
Transform obj2;

private bool IsOverlap ()
{
return obj1.position.x> obj2.position.x && obj1.position.x + obj1.lossyScale.x < obj2.position.x + obj2.lossyScale.x && obj1.position.y> obj2.position.y && obj1.position.y + obj1.lossyScale.y < obj2.position.y + obj2.lossyScale.y && obj1.position.z > obj2.position.z;
}