# Picking Sprites

> Learn about picking sprites in Babylon.js.

Source: https://doc.babylonjs.com/features/featuresDeepDive/sprites/picking_sprites

## Picking
Sprites managed by either the sprite or packed manager can be selected, or picked, provided both the sprite and the manager are set to pickable. This is done as follows:

```javascript
mySpriteManager.isPickable = true;
mySpritePackedManager.isPickable = true;
mySprite.isPickable = true;
```

To do so, you need to:
- Turn on picking on the sprites you want: `sprite.isPickable = true;`
- Enable SpriteManager to support picking: `spriteManager.isPickable = true;`

To perform picking, you can use `scene.pickSprite`:

```
var pickResult = scene.pickSprite(this.pointerX, this.pointerY);
if (pickResult.hit) {
	pickResult.pickedSprite.angle += 0.5;
}
```

Pick and rotate selected sprite with sprite manager: [Playground: Pick And Rotate A Selected Sprite](https://playground.babylonjs.com/#YCY2IL#9) - Simple example of picking a sprite and rotating it.
Pick and rotate selected sprite with sprite packed manager: [Playground: Pick and Rotate A Selected Sprite With Sprite Packed Manager](https://playground.babylonjs.com/#YCY2IL#10) - Simple example of selecting a sprite from a sprite packed manager and rotating it.

For performance reasons, the default is to indicate a hit if the sprite is picked within its bounding rectangle. If you do not want a hit inside a transparent region of the sprite, you need to add the following:
```javascript
mySprite.useAlphaForPicking = true;
```
and picking will only work if alpha > 0.5.

Transparent regions not reacting to pick: [Playground: Transparent Regions No Picking](https://playground.babylonjs.com/#YCY2IL#11) - Simple example showing how you cannot pick transparent regions of sprites.


When sprites overlap, you can use *multiPickSprite* to get all the sprites under the mouse:

```
const pickResult = scene.multiPickSprite(this.pointerX, this.pointerY);
for (let i = 0; i < pickResult.length; i++) {
    	pickResult[i].pickedSprite.angle += Math.PI / 4;
}
```

Multipicking of overlapping sprites: [Playground: Multipicking Overlapping Sprites](https://playground.babylonjs.com/#YCY2IL#12) - Simple example of multipicking of overlapping sprites.
