# How to move character with mouse click?

**URL:** <https://forums.unrealengine.com/t/how-to-move-character-with-mouse-click/400995>\
**Category:** Character & Animation\
**Tags:** mouse-cursor, unreal-engine, mouse-position, UE4, CPP, question\
**Created:** [August 1, 2017, 2:26pm UTC](https://forums.unrealengine.com/t/how-to-move-character-with-mouse-click/400995 "2017-08-01T14:26:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lueha55](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@lueha55](https://forums.unrealengine.com/u/lueha55)\
**Post date:** [August 1, 2017, 2:26pm UTC](https://forums.unrealengine.com/t/how-to-move-character-with-mouse-click/400995/1 "2017-08-01T14:26:26Z")

</div>

i m sorry for poor English.  
I’d like to move to the destination with mouse click.  
(destination = mouse click pos)

* * *

```
void ABaseCharacter::SetupPlayerInputComponent(class UInputComponent* InputComponent){
	Super::SetupPlayerInputComponent(InputComponent);
	InputComponent->BindAction("GetMousePos", IE_Pressed, this, &ABaseCharacter::GetMouseClicked);
}

// Called every frame
void ABaseCharacter::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );
	//or GetMouseCliecked HERE?
}   
void ABaseCharacter::GetMouseClicked(){
	FVector2D mousePos = FVector2D(0, 0);
	APlayerController* pc = GetWorld()->GetFirstPlayerController();
	pc->GetMousePosition(mousePos.X, mousePos.Y);

	FVector worldPos = FVector(mousePos.X, mousePos.Y, 0);
	FVector dir = FVector(0, 0, 0);	

	pc->DeprojectMousePositionToWorld(worldPos, dir);

	AddMovementInput(worldPos, Speed);	
}

```

* * *

Did I do anything wrong in code?

and How do I make a mouse show when I play games?

What should I do? I need help …

---

<div class="post-metadata">

**Author:** ![Nachtmahr](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nachtmahr](https://forums.unrealengine.com/u/Nachtmahr)\
**Post date:** [August 1, 2017, 3:11pm UTC](https://forums.unrealengine.com/t/how-to-move-character-with-mouse-click/400995/2 "2017-08-01T15:11:04Z")

</div>

Yes probably a couple things. I would suggest to you that you create a new UE4 C++ Project of Top Down Template. Learn from the Code its easier to explain it here.

---

<div class="post-metadata">

**Author:** ![lueha55](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@lueha55](https://forums.unrealengine.com/u/lueha55)\
**Post date:** [August 2, 2017, 10:48am UTC](https://forums.unrealengine.com/t/how-to-move-character-with-mouse-click/400995/3 "2017-08-02T10:48:50Z")

</div>

I don’t know how to use it. Could you explain it a little bit more?
