# FreeMoveHandle

> Make an unconstrained movement handle.

## Definition

* **Type:** Method
* **Namespace:** [UnityEditor](/engine/6000.0/script-reference/unityeditor.md)
* **Assembly:** UnityEditor

## FreeMoveHandle(Vector3, float, Vector3, CapFunction)

Make an unconstrained movement handle.

```csharp
public static Vector3 FreeMoveHandle(Vector3 position, float size, Vector3 snap, Handles.CapFunction capFunction)
```

### Parameters

**** (\[Vector3]\(/engine/6000.0/script-reference/unityengine/vector3)): The position of the handle in the space of [Handles.matrix](/engine/6000.0/script-reference/unityeditor/handles/matrix.md).**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The size of the handle in the space of [Handles.matrix](/engine/6000.0/script-reference/unityeditor/handles/matrix.md). Use [HandleUtility.GetHandleSize](/engine/6000.0/script-reference/unityeditor/handleutility/gethandlesize.md) if you want a constant screen-space size.**** (\[Vector3]\(/engine/6000.0/script-reference/unityengine/vector3)): The snap increment on all axes. See [Handles.SnapValue](/engine/6000.0/script-reference/unityeditor/handles/snapvalue.md).**** (\[CapFunction]\(/engine/6000.0/script-reference/unityeditor/handles/capfunction)): The function to call for doing the actual drawing.

### Returns

| Type                                                              | Description                                                                                                                                                            |
| ----------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Vector3](/engine/6000.0/script-reference/unityengine/vector3.md) | The new value modified by the user's interaction with the handle. If the user has not moved the handle, it will return the same value as you passed into the function. |

### Remarks

This handle can move freely in all directions. Hold down Ctrl (Cmd on macOS) to snap to the grid (see [PositioningGameObjects](/engine/6000.0/manual/working-with-scenes/scenes-manage-gameobjects/positioning-game-objects.md)). Hold Ctrl-Shift (Cmd-Shift on macOS) to snap the object to any Collider surface under the mouse pointer.

![FreeMoveHandle (FreeMoveHandle)](/api/media?file=/engine/6000.0/media/images/FreeMoveHandle.png)

*Free Move handle in the Scene View.*

Add the following script to your Assets folder as FreeMoveHandleExample.cs and add the FreeMoveHandleExample component to an object in a Scene.

```csharp
using UnityEngine;

[ExecuteInEditMode]
public class FreeMoveHandleExample : MonoBehaviour
{
    public Vector3 targetPosition { get { return m_TargetPosition; } set { m_TargetPosition = value; } }
    [SerializeField]
    private Vector3 m_TargetPosition = new Vector3(1f, 0f, 2f);

    public virtual void Update()
    {
        transform.LookAt(m_TargetPosition);
    }
}
```

Add the following script to Assets/Editor as FreeMoveHandleExampleEditor.cs and select the object with the FreeMoveHandleExample component.

```csharp
using UnityEditor;
using UnityEngine;

[CustomEditor(typeof(FreeMoveHandleExample)), CanEditMultipleObjects]
public class FreeMoveHandleExampleEditor : Editor
{
    protected virtual void OnSceneGUI()
    {
        FreeMoveHandleExample example = (FreeMoveHandleExample)target;

        float size = HandleUtility.GetHandleSize(example.targetPosition) * 0.5f;
        Vector3 snap = Vector3.one * 0.5f;

        EditorGUI.BeginChangeCheck();
        Vector3 newTargetPosition = Handles.FreeMoveHandle(example.targetPosition, size, snap, Handles.RectangleHandleCap);
        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(example, "Change Look At Target Position");
            example.targetPosition = newTargetPosition;
            example.Update();
        }
    }
}
```

## FreeMoveHandle(int, Vector3, float, Vector3, CapFunction)

Make an unconstrained movement handle.

```csharp
public static Vector3 FreeMoveHandle(int controlID, Vector3 position, float size, Vector3 snap, Handles.CapFunction capFunction)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The control ID for the handle.**** (\[Vector3]\(/engine/6000.0/script-reference/unityengine/vector3)): The position of the handle in the space of [Handles.matrix](/engine/6000.0/script-reference/unityeditor/handles/matrix.md).**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The size of the handle in the space of [Handles.matrix](/engine/6000.0/script-reference/unityeditor/handles/matrix.md). Use [HandleUtility.GetHandleSize](/engine/6000.0/script-reference/unityeditor/handleutility/gethandlesize.md) if you want a constant screen-space size.**** (\[Vector3]\(/engine/6000.0/script-reference/unityengine/vector3)): The snap increment on all axes. See [Handles.SnapValue](/engine/6000.0/script-reference/unityeditor/handles/snapvalue.md).**** (\[CapFunction]\(/engine/6000.0/script-reference/unityeditor/handles/capfunction)): The function to call for doing the actual drawing.

### Returns

| Type                                                              | Description                                                                                                                                                            |
| ----------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Vector3](/engine/6000.0/script-reference/unityengine/vector3.md) | The new value modified by the user's interaction with the handle. If the user has not moved the handle, it will return the same value as you passed into the function. |

### Remarks

This handle can move freely in all directions. Hold down Ctrl (Cmd on macOS) to snap to the grid (see [PositioningGameObjects](/engine/6000.0/manual/working-with-scenes/scenes-manage-gameobjects/positioning-game-objects.md)). Hold Ctrl-Shift (Cmd-Shift on macOS) to snap the object to any Collider surface under the mouse pointer.

![FreeMoveHandle (FreeMoveHandle)](/api/media?file=/engine/6000.0/media/images/FreeMoveHandle.png)

*Free Move handle in the Scene View.*

Add the following script to your Assets folder as FreeMoveHandleExample.cs and add the FreeMoveHandleExample component to an object in a Scene.

```csharp
using UnityEngine;

[ExecuteInEditMode]
public class FreeMoveHandleExample : MonoBehaviour
{
    public Vector3 targetPosition { get { return m_TargetPosition; } set { m_TargetPosition = value; } }
    [SerializeField]
    private Vector3 m_TargetPosition = new Vector3(1f, 0f, 2f);

    public virtual void Update()
    {
        transform.LookAt(m_TargetPosition);
    }
}
```

Add the following script to Assets/Editor as FreeMoveHandleExampleEditor.cs and select the object with the FreeMoveHandleExample component.

```csharp
using UnityEditor;
using UnityEngine;

[CustomEditor(typeof(FreeMoveHandleExample)), CanEditMultipleObjects]
public class FreeMoveHandleExampleEditor : Editor
{
    protected virtual void OnSceneGUI()
    {
        FreeMoveHandleExample example = (FreeMoveHandleExample)target;

        float size = HandleUtility.GetHandleSize(example.targetPosition) * 0.5f;
        Vector3 snap = Vector3.one * 0.5f;

        EditorGUI.BeginChangeCheck();
        Vector3 newTargetPosition = Handles.FreeMoveHandle(example.targetPosition, size, snap, Handles.RectangleHandleCap);
        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(example, "Change Look At Target Position");
            example.targetPosition = newTargetPosition;
            example.Update();
        }
    }
}
```
