Download

C++ Cursor Coordinates to game level coordinate help

Hi guys!

I have what I hope is a easy question for you guys.

Is there a way to convert mouse cursor location on the screen to my games world coordinates?

I will start by saying that my game is a 2D side scroller. So, my mouse coordinates when I click on something would be X, Y. What I need to do is be able to click somewhere, anywhere and get my mouse cursor X, Y coordinates(I have done this part already) and then get what the level coordinates would be for that exact spot. Does that make sense?

I have set up a small example that I am trying to work with. Here it is:

CPP file:

#include “CursorCOORDtoGameLoc.h”
#include “testClickConvert.h”

// Sets default values
AtestClickConvert::AtestClickConvert()
{
FVector myVector = FVector(0.0f, 0.0f, 0.0f);

//Assume that these two variables are my cursor coordinates when I click on something
int32 numX = 5;
int32 numZ = 10;


//How would I get the world location values for numX and numZ
//and assign them to the X and Z values of myVector???

}

Any ideas? And thank you in advance.

This is what you are looking for.