Attempted to re-create the Cursor to World transform, using blueprints. However, it needs fixing.

Hi there,

I’m currently working on an ARPG game, with a heavy focus on writing my own code (even though I’m a laic when it comes to coding, or writing visual scripts; but had some prior success already, with some A*). That being said, the project hit a roadblock, of which I’m not entirely sure how to solve; as the information I managed to find so far (after days of searching) didn’t prove to be useful (partially because I couldn’t understand nor implement correctly). Hence I thought to ask you folks about it.

The aim is to recreate the cursor-to-world pipeline with actual scripting, rather than using the built in functions. I’ve opted out from using all the "black box" nodes (e.g.: GetHitResultUnderCursor, DeprojectScreen, etc.), for numerous reasons; but more importantly for better control for later use (for mechanics). As I couldn’t find much in this topic (UE4 specific, in this regard, not using the default nodes), I went on and tried to implement this (preview below), using a more traditional approach, seen in coding (like creating 4D vectors, and using matrix transformations). As platforms differ from one to another, the code I found online was hard to read most of the time (in some cases it looked completely gibberish to me), but I managed to find a couple of interesting videos and tutorials for other engines/languages, which helped me out quite a lot. Ultimately, I settled on using this pipeline, from this website: Mouse Picking with Ray Casting.

The result looks something like this (preview). You can find the complete code here:

The issue is that the transformation of the screen space doesn’t work properly, and I get incorrect values at the end of the node chain (not even when centering the cursor on screen); which I wish to hook up to a trace at some point. Supposedly, I should be getting values within a range of +/- 1, but the numbers I get are only a fraction of a number (and barely move by 1 or 2 thousandths). So as an example: You see Y=0.001, and when I move the mouse to the edge of the screen, it only shifts from -0.003 to 0.003). Which obviously I can’t use for tracing at all. Tried to modify how the calculation worked, even tried to manually create the projection matrix, but that didn’t work either. I suspect that the issue is with the normalized X and Y, because they get really low, before the first 4D vector.


I though that–in theory–this node setup should work, but for reasons unbeknownst to me, it doesn’t. That’s why I’m asking you folks out there, if you could point out my obvious mistakes, and nudge this code forward, to make it function. Thanks in advance! :slight_smile: