Esempio n. 1
0
void AECommanderPawn::Tick(float DeltaSeconds)
{
	Super::Tick(DeltaSeconds);

	// Get the game viewport and make sure it exists as there is no
	// guarantee that it does.
	UGameViewportClient* GameViewport = GEngine->GameViewport;
	if (!GameViewport)
	{
		return;
	}

	// Get the position of the mouse on the screen.
	FVector2D MousePosition;
	GameViewport->GetMousePosition(MousePosition);

	// Get the size of the screen.
	FVector2D ViewportSize;
	GameViewport->GetViewportSize(ViewportSize);

	// Make sure the game view port has focus (contains the mouse).
	if (!GameViewport->IsFocused(GameViewport->Viewport))
	{
		return;
	}

	// Check if the mouse is at the left or right side of the
	// screen and move accordingly.
	if (MousePosition.X < CameraScrollBoundary)
	{
	}
	else if ((ViewportSize.X - MousePosition.X) < CameraScrollBoundary)
	{
	}

	// Check if the mouse is at the top or bottom of the screen
	// and move accordingly.
	if (MousePosition.Y < CameraScrollBoundary)
	{
	}
	else if ((ViewportSize.Y - MousePosition.Y) < CameraScrollBoundary)
	{
	}
}
void AMainCameraSpecPawn::Tick(float DeltaSeconds) {
	Super::Tick(DeltaSeconds);

	FVector2D MousePosition;
	FVector2D ViewportSize;

	UGameViewportClient* GameViewport = GEngine->GameViewport;

	check(GameViewport);
	GameViewport->GetViewportSize(ViewportSize);

	// Check if input is detectable
	if (GameViewport->IsFocused(GameViewport->Viewport) &&
		GameViewport->GetMousePosition(MousePosition) &&
		bCanMoveCamera) {

		// Edge of screen movement
		if (MousePosition.X < CameraScrollBounds) {
			YMovement = -1.0f;
		} else if (ViewportSize.X - MousePosition.X < CameraScrollBounds) {
			YMovement = 1.0f;
		}

		if (MousePosition.Y < CameraScrollBounds) {
			XMovement = 1.0f;
		}
		else if (ViewportSize.Y - MousePosition.Y < CameraScrollBounds) {
			XMovement = -1.0f;
		}

		// movement
		MoveCameraForward(XMovement * FastMoveMultiplier * DeltaSeconds);
		MoveCameraRight(YMovement * FastMoveMultiplier * DeltaSeconds);

	}
	
}