@@ -67,6 +67,25 @@ static PyObject *py_unreal_engine_add_on_screen_debug_message(PyObject * self, P
6767 return Py_None;
6868}
6969
70+ static PyObject *py_unreal_engine_find_class (PyObject * self, PyObject * args) {
71+ char *name;
72+ if (!PyArg_ParseTuple (args, " s:find_class" , &name)) {
73+ return NULL ;
74+ }
75+
76+ UClass *u_class = FindObject<UClass>(ANY_PACKAGE, UTF8_TO_TCHAR (name));
77+
78+ if (u_class) {
79+ ue_PyUObject *ret = ue_get_python_wrapper (u_class);
80+ if (!ret)
81+ return PyErr_Format (PyExc_Exception, " uobject is in invalid state" );
82+ Py_INCREF (ret);
83+ return (PyObject *)ret;
84+ }
85+
86+ Py_INCREF (Py_None);
87+ return Py_None;
88+ }
7089
7190
7291/*
@@ -81,6 +100,7 @@ static PyMethodDef unreal_engine_methods[] = {
81100 { " log_warning" , py_unreal_engine_log_warning, METH_VARARGS, " " },
82101 { " log_error" , py_unreal_engine_log_error, METH_VARARGS, " " },
83102 { " add_on_screen_debug_message" , py_unreal_engine_add_on_screen_debug_message, METH_VARARGS, " " },
103+ { " find_class" , py_unreal_engine_find_class, METH_VARARGS, " " },
84104 { NULL , NULL },
85105};
86106
@@ -215,6 +235,30 @@ static PyObject *py_ue_get_actor_location(ue_PyUObject *self, PyObject * args) {
215235
216236}
217237
238+ static PyObject *py_ue_get_actor_velocity (ue_PyUObject *self, PyObject * args) {
239+
240+ ue_py_check (self);
241+
242+ FVector vec3;
243+
244+ if (self->ue_object ->IsA <AActor>()) {
245+ vec3 = ((AActor *)self->ue_object )->GetVelocity ();
246+ goto ret;
247+ }
248+
249+ if (self->ue_object ->IsA <UActorComponent>()) {
250+ vec3 = ((UActorComponent *)self->ue_object )->GetOwner ()->GetVelocity ();
251+ goto ret;
252+ }
253+
254+
255+ return PyErr_Format (PyExc_Exception, " uobject is not an actor or a component" );
256+
257+ ret:
258+ return Py_BuildValue (" fff" , vec3.X , vec3.Y , vec3.Z );
259+
260+ }
261+
218262static PyObject *py_ue_get_input_axis (ue_PyUObject *self, PyObject * args) {
219263
220264 ue_py_check (self);
@@ -459,10 +503,33 @@ static PyObject *py_ue_all_actors(ue_PyUObject * self, PyObject * args) {
459503 return ret;
460504}
461505
506+ static PyObject *py_ue_actor_components (ue_PyUObject * self, PyObject * args) {
507+
508+ ue_py_check (self);
509+
510+ if (!self->ue_object ->IsA <AActor>()) {
511+ return PyErr_Format (PyExc_Exception, " uobject is not an AActor" );
512+ }
513+
514+ AActor *actor = (AActor *)self->ue_object ;
515+
516+ PyObject *ret = PyList_New (0 );
517+
518+ for (UActorComponent *component : actor->GetComponents ()) {
519+ ue_PyUObject *py_obj = ue_get_python_wrapper (component);
520+ if (!py_obj)
521+ continue ;
522+ PyList_Append (ret, (PyObject *)py_obj);
523+ }
524+
525+ return ret;
526+ }
527+
462528static PyObject *py_ue_is_a (ue_PyUObject *, PyObject *);
463529
464530static PyMethodDef ue_PyUObject_methods[] = {
465531 { " get_actor_location" , (PyCFunction)py_ue_get_actor_location, METH_VARARGS, " " },
532+ { " get_actor_velocity" , (PyCFunction)py_ue_get_actor_velocity, METH_VARARGS, " " },
466533 { " set_actor_location" , (PyCFunction)py_ue_set_actor_location, METH_VARARGS, " " },
467534 { " get_property" , (PyCFunction)py_ue_get_property, METH_VARARGS, " " },
468535 { " properties" , (PyCFunction)py_ue_properties, METH_VARARGS, " " },
@@ -478,6 +545,7 @@ static PyMethodDef ue_PyUObject_methods[] = {
478545 { " bind_input_axis" , (PyCFunction)py_ue_bind_input_axis, METH_VARARGS, " " },
479546 { " enable_input" , (PyCFunction)py_ue_enable_input, METH_VARARGS, " " },
480547 { " get_class" , (PyCFunction)py_ue_get_class, METH_VARARGS, " " },
548+ { " actor_components" , (PyCFunction)py_ue_actor_components, METH_VARARGS, " " },
481549 { NULL } /* Sentinel */
482550};
483551
0 commit comments