No problems, let's try to get things going for you.
If you can retrieve the 2D mouse coordinates via Scaleform, mouse delta appending or reading from the system coordinates then you're half way there.
The next thing you want to do is to calculate the 3D plane coordinates. Imagine your screen is the plane, and somewhere on this plane is the coordinates of where the 2D mouse coordinates is. This is what the Canvas.DeProject() function does for you. DeProject() returns two vectors. One vector represents the point on the plane (blue dot), and the other vector represents the direction which you can use to perform a trace (blue line).

Code:
// MousePosition is the 2D coordinates representing the mouse in screen space.
function MouseInteract(Vector2D MousePosition)
{
local Vector MouseWorldOrigin, MouseWorldDirection, HitLocation, HitNormal;
local Actor HitActor;
// Ensure that we have a valid canvas and player owner
if (Canvas == None)
{
return Vect(0, 0, 0);
}
// Deproject the mouse position and store it
Canvas.DeProject(MousePosition, MouseWorldOrigin, MouseWorldDirection);
// Perform a trace to get the actor the mouse is hovering over
HitActor = Trace(HitLocation, HitNormal, MouseWorldOrigin + MouseWorldDirection * 65536.f, MouseWorldOrigin , true,,, TRACEFLAG_Bullet);
// Do what you want with Actor, HitLocation and HitNormal
}
The code snippet above, shows how you use the deprojected 2D coordinates to then perform a trace within the world. The Actor that the trace returns is the actor that is "underneath" the mouse cursor.
If the HitActor is WorldInfo, then the trace has hit BSP. If the HitActor is None, then the trace did not hit anything. Otherwise the trace will an actor in the world.
The HitLocation is a point in the world where the trace hit. This is usually garbage or Vect(0, 0, 0) if the trace did not hit anything.
The HitNormal is a direction vector that is equivalent of the surface normal of the surface that the trace hit. This is garbage if the trace did not hit anything.
So with that out of the way, the next question is how you would go about linking this with the mouse or the button press. So one thing you need to be very careful is the order you do things. While you can use DeProject from within LocalPlayer, it is slower than the one in Canvas. So for performance reasons, what I usually do is when a player presses a button to execute an exec function; I would then cache it as a pending action. Then when the Canvas is ready, I then check if there is a pending action, and from there I gather what actor the mouse is over and then perform actions.
Bookmarks