@@ -1250,6 +1250,48 @@ static PyObject *py_ue_line_trace_multi_by_channel(ue_PyUObject * self, PyObject
12501250
12511251}
12521252
1253+ static PyObject *py_ue_get_hit_result_under_cursor (ue_PyUObject * self, PyObject * args) {
1254+
1255+ ue_py_check (self);
1256+
1257+ int channel;
1258+ PyObject *trace_complex = NULL ;
1259+
1260+ UWorld *world = ue_get_uworld (self);
1261+ if (!world)
1262+ return PyErr_Format (PyExc_Exception, " unable to retrieve UWorld from uobject" );
1263+
1264+
1265+ if (!PyArg_ParseTuple (args, " i|O:get_hit_result_under_cursor" , &channel, &trace_complex)) {
1266+ return NULL ;
1267+ }
1268+
1269+
1270+ bool complex = false ;
1271+ if (trace_complex && PyObject_IsTrue (trace_complex)) {
1272+ complex = true ;
1273+ }
1274+
1275+ APlayerController *controller = world->GetFirstPlayerController ();
1276+
1277+ if (!controller)
1278+ return PyErr_Format (PyExc_Exception, " unable to find first player controller" );
1279+
1280+ FHitResult hit;
1281+
1282+ bool got_hit = controller->GetHitResultUnderCursor ((ECollisionChannel)channel, complex , hit);
1283+
1284+ if (got_hit) {
1285+ PyObject *ret = (PyObject *)ue_get_python_wrapper (hit.GetActor ());
1286+ if (!ret)
1287+ return PyErr_Format (PyExc_Exception, " uobject is in invalid state" );
1288+ return Py_BuildValue (" Offffff" , ret, hit.ImpactPoint .X , hit.ImpactPoint .Y , hit.ImpactPoint .Z , hit.ImpactNormal .X , hit.ImpactNormal .Y , hit.ImpactNormal .Z );
1289+ }
1290+
1291+ return Py_BuildValue (" Offffff" , Py_None, 0 , 0 , 0 , 0 , 0 , 0 );
1292+
1293+ }
1294+
12531295
12541296
12551297static PyObject *py_ue_is_a (ue_PyUObject *, PyObject *);
@@ -1299,6 +1341,7 @@ static PyMethodDef ue_PyUObject_methods[] = {
12991341 { " get_actor_bounds" , (PyCFunction)py_ue_get_actor_bounds, METH_VARARGS , " " },
13001342 { " line_trace_single_by_channel" , (PyCFunction)py_ue_line_trace_single_by_channel, METH_VARARGS , " " },
13011343 { " line_trace_multi_by_channel" , (PyCFunction)py_ue_line_trace_multi_by_channel, METH_VARARGS , " " },
1344+ { " get_hit_result_under_cursor" , (PyCFunction)py_ue_get_hit_result_under_cursor, METH_VARARGS , " " },
13021345 { " show_mouse_cursor" , (PyCFunction)py_ue_show_mouse_cursor, METH_VARARGS , " " },
13031346 { " enable_click_events" , (PyCFunction)py_ue_enable_click_events, METH_VARARGS , " " },
13041347 { " enable_mouse_over_events" , (PyCFunction)py_ue_enable_mouse_over_events, METH_VARARGS , " " },
0 commit comments