@@ -1024,6 +1024,7 @@ static PyObject *py_ue_add_actor_component(ue_PyUObject *, PyObject *);
10241024static PyObject *py_ue_get_actor_component_by_type (ue_PyUObject *, PyObject *);
10251025static PyObject *py_ue_add_actor_root_component (ue_PyUObject *, PyObject *);
10261026static PyObject *py_ue_play_sound_at_location (ue_PyUObject *, PyObject *);
1027+ static PyObject *py_ue_get_overlapping_actors (ue_PyUObject *, PyObject *);
10271028
10281029static PyMethodDef ue_PyUObject_methods[] = {
10291030
@@ -1158,6 +1159,8 @@ static PyMethodDef ue_PyUObject_methods[] = {
11581159 { " get_num_players" , (PyCFunction)py_ue_get_num_players, METH_VARARGS , " " },
11591160 { " get_num_spectators" , (PyCFunction)py_ue_get_num_spectators, METH_VARARGS , " " },
11601161
1162+ { " get_overlapping_actors" , (PyCFunction)py_ue_get_overlapping_actors, METH_VARARGS , " " },
1163+
11611164 { NULL } /* Sentinel */
11621165};
11631166
@@ -1496,6 +1499,47 @@ static PyObject *py_ue_is_a(ue_PyUObject * self, PyObject * args) {
14961499 return Py_False;
14971500}
14981501
1502+ static PyObject *py_ue_get_overlapping_actors (ue_PyUObject * self, PyObject * args) {
1503+
1504+ ue_py_check (self);
1505+
1506+ AActor *actor = ue_get_actor (self);
1507+ if (!actor)
1508+ return PyErr_Format (PyExc_Exception, " cannot retrieve actor from UObject" );
1509+
1510+ PyObject *class_filter = nullptr ;
1511+ if (!PyArg_ParseTuple (args, " |O:get_overlapping_actors" , &class_filter)) {
1512+ return NULL ;
1513+ }
1514+
1515+ UClass *filtering = AActor::StaticClass ();
1516+
1517+ if (class_filter) {
1518+
1519+ if (!PyObject_IsInstance (class_filter, (PyObject *)&ue_PyUObjectType))
1520+ return PyErr_Format (PyExc_Exception, " argument is not a UObject" );
1521+
1522+ ue_PyUObject *py_obj = (ue_PyUObject *)class_filter;
1523+
1524+ if (!py_obj->ue_object ->IsA ((UClass *)py_obj->ue_object ))
1525+ return PyErr_Format (PyExc_Exception, " argument is not a UClass" );
1526+
1527+ filtering = (UClass *)py_obj->ue_object ;
1528+ }
1529+
1530+ PyObject *py_overlapping_actors = PyList_New (0 );
1531+
1532+ TArray<AActor *> overalpping_actors;
1533+ actor->GetOverlappingActors (overalpping_actors, filtering);
1534+
1535+ for (AActor *overlapping_actor : overalpping_actors) {
1536+ ue_PyUObject *item = ue_get_python_wrapper (overlapping_actor);
1537+ if (item)
1538+ PyList_Append (py_overlapping_actors, (PyObject *)item);
1539+ }
1540+ return py_overlapping_actors;
1541+ }
1542+
14991543static PyObject *py_ue_destructible_apply_damage (ue_PyUObject * self, PyObject * args) {
15001544
15011545 ue_py_check (self);
@@ -1660,6 +1704,18 @@ UWorld *ue_get_uworld(ue_PyUObject *py_obj) {
16601704 return nullptr ;
16611705}
16621706
1707+ AActor *ue_get_actor (ue_PyUObject *py_obj) {
1708+ if (py_obj->ue_object ->IsA <AActor>()) {
1709+ return (AActor *)py_obj->ue_object ;
1710+ }
1711+
1712+ if (py_obj->ue_object ->IsA <UActorComponent>()) {
1713+ UActorComponent *tmp_component = (UActorComponent *)py_obj->ue_object ;
1714+ return tmp_component->GetOwner ();
1715+ }
1716+ return nullptr ;
1717+ }
1718+
16631719PyObject *ue_py_convert_property (UProperty *prop, uint8 *buffer) {
16641720 if (auto casted_prop = Cast<UBoolProperty>(prop)) {
16651721 bool value = casted_prop->GetPropertyValue_InContainer (buffer);
0 commit comments