Announcement

Collapse
No announcement yet.

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

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

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

    Code:
    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 ?

    #2
    Originally posted by Gunschlinger View Post
    Code:
    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?

    Comment


      #3
      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

      Comment


        #4
        i already got it guys ^^ thanks

        Comment

        Working...
        X