Instantiate a sprite inside bounds of other sprite?

I want to instantiate sprite inside bounds of custom shaped sprite(not box or circle).
I tried using an “other” object and collider to check the “other” object positions
are inside the bounds but it takes time and the game slows down.
does anyone know a better way to solve this problem?

Hi how are you? I don’t know when you say “other” object you mean to not have a reference at all of the object, if you do, well you can calculate the bounds of the sprite by creating an empy game object and getting the coordinates where you want it to be instantiate it . Example . Get the start x point, get the end x point , Y start, Y end (all done manually by placing the empty game object you create it to check where these coordinates are in the world ) and later divide both end and start to get the center of the X and Y bound and use these in your new Vector3() you have to place in the instante function.

Otherwise, if you can reference, get the reference of the renderer of the sprite and later

Bounds ti = Object.GetComponent<Renderer>().bounds;
Vector3 ola =;
Instantiate (test,  ola ,transform.rotation  );	 

With this code, you’ll get an object of the same size that always instantes itself.



Object being the object that has the bounds and test the prefab you’re instantiating.
Important things to take in to account, the object being instantated has to be the same or less size than the object that has the bounds, if not, you’ll have to scale it.

More information regarding how to calculate bounds