[SOLVED] Getting "-" when I look forward

As I have followed the example on screen and on the UE4 site I should have all the info entered correctly. However my forward position X is negative. I don’t know why that would be or even if I should care at this point. Any thoughts?

bool ATankPlayerController::GetSightRayHitLocation(FVector& HitLocation) const
{
//find the crosshair position in pixel coordinates
int32 ViewportSizeX, ViewportSizeY;
GetViewportSize(ViewportSizeX, ViewportSizeY);
auto ScreenLocation = FVector2D(ViewportSizeX * CrosshairXLocation, ViewportSizeY * CrosshairYLocation);

// Deproject the screen position, of the crosshair, to a world position
FVector CameraWorldLocation;
FVector WorldDirection;
if (DeprojectScreenPositionToWorld(ScreenLocation.X, ScreenLocation.Y, CameraWorldLocation, WorldDirection))
{
	UE_LOG(LogTemp, Warning, TEXT("Look direction: %s"), *WorldDirection.ToString())
}

After looking over UE4 I see that my “X” position IS negative based on the player start position. Still am not sure why that would be. I would think that by assigning something to the player start I would have it point in the positive X.

Those are world coordinates not relative coordinates. i.e. look at the position of your landscape, if you move it so that 0, 0, 0 is in the middle of your landscape then looking at that spot would log out 0,0,0

OK… I understand. I did not set my Player start point at 0.0 so depending on where it was set that will be where I am looking. It still seemed strange that anything to the forward part of my tank comes in at a negative value. But after playing with it I found that my player Start had been turned. I fixed it so that I can follow along without it being a problem.

Why is that strange?

Seemed strange that I would have placed my tank , in the world, looking at the negative and not the positive. I must have done it when I was creating my landscape and moving the player start around.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms