The last couple of weeks I have been busy learning how to work with UnrealScript/UDK. Yesterday I have made a 'simple' "place an object where you click" testmechanic. I write 'simple' between quotes because it took me quite a while before I understood what the values I was working with actually meant. For those familiar with UnrealScript: I wasn't sure what the Canvas.DeProject function out-params, WorldOrigin and WorldDirection, were supposed to be/do, which made doing a decent Trace impossible. Thinking my world's orientation was different than it actually was didn't help too much either when I was trying to figure out what I was doing wrong. Anyway, here are three screenshots showing the progress I made yesterday, because after hours and hours staring at the debug-log I am proud of what I eventually have accomplished, even though it is nothing too fancy or original.
1. First results - Clicking all over the screen resulted only in different rotations of the placed object, the object is always placed at coordinates (0,0,0). Still not sure why the rotation changed, I didn't set it anywhere myself..
2. This looks better, but the only way to change the location of the object-creation was by moving around the camera: the object always spawned at the center of the camera, no matter where on the screen I clicked.
3. Final result - The objects are placed exactly where I click, as demonstrated by the mousecursor and the object at the same location.
I probably could have downloaded the code from the internet, but I did create and figure this out all by myself because it is supposed to be a learning experience. Downloading code != learning.
That was all for today to be honest. Just being glad I solved the problem and sharing it with the world! :) I will probably post some more about this UDK project in the future, because believe it or not: this is me working towards an actual game prototype (and preparing for my internship, where I will be using UDK as well).