Point and click examples?

I’m developing a chess game in Unreal to allow me to ease into the coding part, aside from actually spawing the correct pawns, are there any examples of point and click? Obviously the user needs to be able to select a piece and a location for it to move to (highlighting this location / moveable locations examples would also be a great help!) but I’m not sure where to begin with it.

Any assistance here would be great!



Hm, the you will just want to line trace from mouse position straight to the group and depending on the State, grab a piece or drop it.

So i would create different States like “CanPick”, “HoldingPiece” and maybe some more to come up with (could also use a bool, but that
is up to you).

Then, you will just want to convert the Mouse Location from screen to World. This is done using this:

/** Variables **/
	FHitResult HitResult(ForceInit);
	FVector2D mousePos = FVector2D(0, 0);
	FVector worldPos = FVector(mousePos.X, mousePos.Y, 0);
	FVector dir = FVector(0, 0, 0);
	/** Set Variables to Positions **/
	GetMousePosition(mousePos.X, mousePos.Y);
	DeprojectMousePositionToWorld(worldPos, dir);

	FVector Start = worldPos;
	FVector End = Start + dir * 10000;

	/** Init Trace Params **/
	FCollisionQueryParams TraceParams(FName(TEXT("TestTrace")), true, GetPawn());
	TraceParams.bTraceComplex = false;
	TraceParams.bTraceAsyncScene = false;
	TraceParams.bReturnPhysicalMaterial = false;

        /** Do Line Trace **/
	if (GetWorld())
		GetWorld()->LineTraceSingle(HitResult, Start, End, ECC_WorldStatic, TraceParams);

“HitResult” then contains the hit actor (HitResult.HitActor) (or not, if you missed). This can be a chess piece or a chess plate part.

The logic which what you want to do with this information is up to you (: