# WorldToCell(Vector3)

> Converts a world position to cell position.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.0/script-reference/unityengine.md)
* **Assembly:** UnityEngine.GridModule

```csharp
public Vector3Int WorldToCell(Vector3 worldPosition)
```

### Parameters

**** (\[Vector3]\(/engine/6000.0/script-reference/unityengine/vector3)): World Position to convert.

### Returns

| Type                                                                    | Description                          |
| ----------------------------------------------------------------------- | ------------------------------------ |
| [Vector3Int](/engine/6000.0/script-reference/unityengine/vector3int.md) | Cell position of the world position. |

### Remarks

A [GridLayout](/engine/6000.0/script-reference/unityengine/gridlayout.md) has no bounds. Cells extend infinitely in every direction from the origin, so any world position maps to the cell that contains it.

### Examples

```csharp
// Snap the GameObject to parent GridLayout
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    void Start()
    {
        GridLayout gridLayout = transform.parent.GetComponentInParent<GridLayout>();
        Vector3Int cellPosition = gridLayout.WorldToCell(transform.position);
        transform.position = gridLayout.CellToWorld(cellPosition);
    }
}
```
