Download

[C++] How can i convert my mousepos to world position?



UWorld* world = GetWorld();

	if (world)
	{
		APlayerController* pc = world->GetFirstPlayerController();
		FVector2D mousePos = FVector2D(0,0);
		FVector& worldpos = FVector(mousePos.X,mousePos.Y,0);
		FVector& dir = FVector(0, 0, 0);
		pc->GetMousePosition(mousePos.X,mousePos.Y);
		pc->DeprojectMousePositionToWorld(worldpos, dir); //I get an error here
	}


The Error :“error C4239: nonstandard extension used : ‘initializing’ : conversion from ‘FVector’ to ‘FVector &’”

what does this mean ? and how can i fix this ?

You’ve got the reference symbol after the variable declaration for worldPos. You don’t need that. it should be:

FVector worldPos =<whatever>

You don’t really want a reference do you?

It means you need to get rid of the two ‘&’ symbols in your code on line 7 & 8 in the above code.

Edit: Ninja’d

i already got it guys ^^ thanks