# Interactive Tool Framework: Gizmo incorrect hits

**URL:** <https://forums.unrealengine.com/t/interactive-tool-framework-gizmo-incorrect-hits/747405>\
**Category:** C++\
**Tags:** unreal-engine, gizmo, runtime, editor, CPP\
**Created:** [January 11, 2023, 11:30pm UTC](https://forums.unrealengine.com/t/interactive-tool-framework-gizmo-incorrect-hits/747405 "2023-01-11T23:30:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gokitty199](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@gokitty199](https://forums.unrealengine.com/u/gokitty199)\
**Post date:** [January 11, 2023, 11:30pm UTC](https://forums.unrealengine.com/t/interactive-tool-framework-gizmo-incorrect-hits/747405/1 "2023-01-11T23:30:39Z")

</div>

I am having a very odd issue with my gizmo using the ITF and I’m at a loss. It’s like the gizmos “hit boxes” are not where they are visually and I cannot figure out why. I made a debug trace to confirm that my mouse is going to the gizmo as intended and it is so I’m not sure whats going on. Example can be seen in the video below

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/8/5/985620791ccece6056ef1225defac73bfd78d556.jpeg "Runtime Gizmo hit issue") ](https://www.youtube.com/watch?v=tHOPRcLqGCQ)

Tick for overlaps/interaction

```auto
FInputDeviceState InputState = CurrentMouseState;
InputState.InputDevice = EInputDevices::Mouse;
FModifierKeysState ModifierState = FSlateApplication::Get().GetModifierKeys();

UGameViewportClient* ViewportClient = GetWorld()->GetGameViewport();

// update modifier keys
InputState.SetModifierKeyStates(
	ModifierState.IsLeftShiftDown(),
	ModifierState.IsAltDown(),
	ModifierState.IsControlDown(),
	ModifierState.IsCommandDown());

if (ViewportClient)
{
	FSceneViewport* Viewport = ViewportClient->GetGameViewport();
	APlayerController* PC = UGameplayStatics::GetPlayerController(GetWorld(), 0);

	ContextQueriesAPI->UpdateActiveViewport(Viewport);
	
	FVector WorldLocation, WorldDirection;
	FVector2D ViewportMousePos;
	
	PC->DeprojectMousePositionToWorld(WorldLocation, WorldDirection);
	PC->GetMousePosition(ViewportMousePos.X, ViewportMousePos.Y);
	
	InputState.Mouse.Position2D = ViewportMousePos;
	InputState.Mouse.Delta2D = CurrentMouseState.Mouse.Position2D - PrevMousePosition;
	PrevMousePosition = InputState.Mouse.Position2D;
	InputState.Mouse.WorldRay = FRay(WorldLocation, WorldDirection);
	FVector Start = WorldLocation + WorldDirection * 25.0f;
	FVector End = Start + WorldDirection * 800.0f;
	DrawDebugLine(GetWorld(), Start, End, FColor::Red, false, -1.0f, 0, 0.2f);

	if (bInCameraControl)
	{
		ensure(bPendingMouseStateChange == false);
		ensure(ToolsContext->InputRouter->HasActiveMouseCapture() == false);
		ToolsContext->InputRouter->PostHoverInputEvent(InputState);
	}
	else if (bPendingMouseStateChange || ToolsContext->InputRouter->HasActiveMouseCapture())
	{
		ToolsContext->InputRouter->PostInputEvent(InputState);
	}
	else
	{
		ToolsContext->InputRouter->PostHoverInputEvent(InputState);
	}

	// clear down or up flags now that we have sent event
	if (bPendingMouseStateChange)
	{
		if (CurrentMouseState.Mouse.Left.bDown)
		{
			UE_LOG(LogTemp, Warning, TEXT("MOUSE DOWN"));
			CurrentMouseState.Mouse.Left.SetStates(false, true, false);
		}
		else
		{
			CurrentMouseState.Mouse.Left.SetStates(false, false, false);
		}
		bPendingMouseStateChange = false;
	}

	// tick things
	ToolsContext->ToolManager->Tick(DeltaSeconds);
	ToolsContext->GizmoManager->Tick(DeltaSeconds);
}

```
