Skip to content

Commit db01c0e

Browse files
author
Roberto De Ioris
committed
2 parents aad8083 + 709c4ea commit db01c0e

File tree

2 files changed

+387
-309
lines changed

2 files changed

+387
-309
lines changed

README.md

Lines changed: 60 additions & 309 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,26 @@ git clone https://github.com/20tab/UnrealEnginePython
5757
* restart the editor and a popup should appear asking your for confirmation of the build of the plugin.
5858
* Once the plugin is built, go to the output log console and filter for 'Python'. You should see the Python VM banner.
5959

60+
Upgrading on MacOSX
61+
-------------------
62+
63+
To upgrade to the latest development version of UnrealEnginePython:
64+
* move to the Plugins directory in the project directory and use git pull
65+
66+
```sh
67+
git pull
68+
```
69+
70+
* move to UnrealEnginePython/Binaries from the Plugin directory
71+
* remove the plugin library UE4Editor-UnrealEnginePython.dylib to warn UnrealEngine to recompile the plugin
72+
73+
```sh
74+
rm UE4Editor-UnrealEnginePython.dylib
75+
```
76+
77+
* restart the editor and a popup should appear asking your for confirmation of the build of the plugin.
78+
* Once the plugin is built, go to the output log console and filter for 'Python'. You should see the Python VM banner.
79+
6080
# Installation on other platforms
6181

6282
Currently only Windows and MacOSX are supported, Linux support should be available soon. We are investigating Android support too via the kivy project.
@@ -321,315 +341,7 @@ Remember, there is no need to implement every single engine class method, the re
321341

322342
Most-used methods are implemented directly as uobject methods for performance reasons.
323343

324-
---
325-
```py
326-
x, y, z = uobject.get_actor_location()
327-
```
328-
329-
get the current actor location (automatically retrieve the actor from the component if needed)
330-
331-
---
332-
```py
333-
uobject.set_actor_location(x, y, z)
334-
```
335-
336-
set the current actor location (automatically retrieve the actor from the component if needed)
337-
338-
---
339-
```py
340-
pitch, yaw, roll = uobject.get_actor_rotation()
341-
```
342-
343-
get the current actor rotation (automatically retrieve the actor from the component if needed)
344-
345-
346-
---
347-
```py
348-
uobject.set_actor_rotation(pitch, yaw, roll)
349-
```
350-
set the current actor rotation (automatically retrieve the actor from the component if needed)
351-
352-
---
353-
```py
354-
x, y, z = uobject.get_actor_forward()
355-
```
356-
357-
get the current actor forward vector (automatically retrieve the actor from the component if needed)
358-
359-
---
360-
```py
361-
x, y, z = uobject.get_actor_right()
362-
```
363-
364-
get the current actor right vector (automatically retrieve the actor from the component if needed)
365-
366-
---
367-
```py
368-
x, y, z = uobject.get_actor_up()
369-
```
370-
371-
get the current actor up vector (automatically retrieve the actor from the component if needed)
372-
373-
---
374-
```py
375-
x, y, z = uobject.get_actor_velocity()
376-
```
377-
get the current actor velocity vector (automatically retrieve the actor from the component if needed)
378-
379-
380-
---
381-
```py
382-
value = uobject.get_property('name')
383-
```
384-
385-
get the property value of a uobject
386-
387-
NOTE: currently only floats and objects values are supported
388-
389-
390-
---
391-
```py
392-
uobject.set_property('name', value)
393-
```
394-
395-
set the property of a uobject
396-
397-
NOTE: currently only floats and strings values are supported
398-
399-
---
400-
```py
401-
properties_list = uobject.properties()
402-
```
403-
404-
get the list of properties available for the uobject (as a list of string names)
405-
406-
---
407-
```py
408-
uobject.call('function arg0 arg1 argN....')
409-
```
410-
411-
this is probably the most important functionality of the Unreal Engine reflection system.
412-
413-
It allows you to call a method/function exposed by a uobject passing it arguments.
414-
415-
For example you have an uobject mapped to a UTextRenderComponent and you want to change the text:
416-
417-
```py
418-
text_render_component.call('SetText Hello')
419-
```
420-
421-
will call the UTextRenderComponent::SetText(FString value) method passing 'Hello' as the string argument
422-
423-
This methods allows you to interface with basically every engine features, but is is obviously slower than directly calling C++ methods.
424-
425-
Use it for calling blueprint functions, or while waiting for the addition of new specific-methods in the uobject api ;)
426-
427-
---
428-
```py
429-
actor = uobject.get_owner()
430-
```
431-
432-
get the owner of an object (generally called by a component to get its actor)
433-
434-
---
435-
```py
436-
world = uobject.get_world()
437-
```
438-
439-
get the world containing an object. (currently useful only for testing and comparison)
440-
441-
---
442-
```py
443-
name = uobject.get_name()
444-
```
445-
get the name of the uobject
446-
447-
---
448-
```py
449-
full_name = uobject.get_full_name()
450-
```
451-
452-
get the full name of the uobject
453-
454-
---
455-
```py
456-
# really slow !
457-
found_uobject = uobject.find_object('name')
458-
```
459-
460-
find an object (by name) in the same world of the caller (SLOW, do not use it unless you know what you are doing)
461-
462-
---
463-
```py
464-
# really really slow !
465-
found_uobjects = uobject.all_objects()
466-
```
467-
468-
get the list of all uobjects in the same world of the caller (REALLY SLOW, do not use it unless you know what you are doing)
469-
470-
---
471-
```py
472-
found_actors = uobject.all_actors()
473-
```
474-
475-
get the list of all actors available in the same world of the caller. A bit slow.
476-
477-
---
478-
```py
479-
uclass = uobject.get_class()
480-
```
481-
482-
this is the same as calling ->GetClass() in c++. You can get the UClass of a uobject.
483-
484-
---
485-
```py
486-
uclass = uobject.actor_spawn(uclass[, x, y, z, pitch, yaw, roll])
487-
```
488-
489-
spawn an actor. uclass is the reference you can get via get_class() or unreal_engine.find_class()
490-
491-
---
492-
```py
493-
uobject.actor_destroy()
494-
```
495-
496-
destroy an actor
497-
498-
---
499-
```py
500-
yesno = uobject.actor_has_component_of_type(uclass)
501-
```
502-
503-
return True if the actor has a component of the specified type
504-
505-
---
506-
```py
507-
yesno = uobject.get_actor_component_by_type(uclass)
508-
```
509-
510-
return the first component (of an actor) of the specified type
511-
512-
---
513-
```py
514-
components = uobject.actor_components()
515-
```
516-
517-
get the list of all components mapped to the actor
518-
519-
---
520-
```py
521-
uobject.enable_input()
522-
```
523-
524-
enable the input system on an object
525-
526-
---
527-
```py
528-
uobject.bind_input_axis('axis')
529-
```
530-
531-
---
532-
```py
533-
uobject.quit_game()
534-
```
535-
536-
well, quit the game :)
537-
538-
---
539-
```py
540-
yesno = uobject.is_input_key_down('key')
541-
```
542-
543-
---
544-
```py
545-
value = uobject.get_input_axis('axis')
546-
```
547-
548-
---
549-
```py
550-
yesno = uobject.actor_has_tag('tagname')
551-
```
552-
553-
check if an actor is tagged with the specific tag
554-
555-
---
556-
```py
557-
x, y, z, ex, ey, ez = uobject.get_actor_bounds()
558-
```
559-
560-
get the bounds of an object (ex, ey and ez are the extents)
561-
562-
---
563-
```py
564-
hit_object, x, y, z, nx, ny, nz = uobject.line_trace_single_by_channel(x0, y1, z0, x1, y1, z1, channel)
565-
```
566-
567-
---
568-
```py
569-
[(hit_object, x, y, z, nx, ny, nz), ...] = uobject.line_trace_multi_by_channel(x0, y1, z0, x1, y1, z1, channel)
570-
```
571-
572-
---
573-
```py
574-
uobject.show_mouse_cursor()
575-
```
576-
577-
---
578-
```py
579-
uobject.enable_click_events()
580-
```
581-
582-
---
583-
```py
584-
uobject.enable_mouse_over_events()
585-
```
586-
587-
---
588-
```py
589-
uobject.destructible_apply_damage(damage, impulse, dx, dy, dz, ix, iy, iz)
590-
```
591-
592-
See Fracturing below
593-
594-
---
595-
```py
596-
uobject.set_view_target(target)
597-
```
598-
599-
change the view target. The 'target' argument should be an actor with a camera component.
600-
601-
---
602-
```py
603-
uobject.set_simulate_physics()
604-
```
605-
606-
---
607-
```py
608-
new_component = uobject.add_actor_component(uclass, 'name')
609-
```
610-
611-
add a new component of the specified uclass (type) and set its name
612-
613-
---
614-
```py
615-
new_component = uobject.add_actor_root_component(uclass, 'name')
616-
```
617-
618-
add a new component as the root one of the specified uclass (type) and set its name
619-
620-
---
621-
```py
622-
uobject.simple_move_to_location(x, y, z)
623-
```
624-
625-
move to a location using navmesh (see Navigation below)
626-
627-
---
628-
```py
629-
clicked_actor, x, y, z, nx, ny, nz = self.uobject.get_hit_result_under_cursor(channel)
630-
```
631-
632-
get the world point under the mouse cursor (see Navigation below, for an example usage)
344+
You can get the the list of uobject api methods here: https://github.com/20tab/UnrealEnginePython/blob/master/uobject_API.md
633345

634346
Automatic module reloading (Editor only)
635347
----------------------------------------
@@ -756,6 +468,45 @@ class DestroyMeComponent:
756468

757469
you can now call the 'explode' method via blueprints using the 'Call Python Component Method' node
758470

471+
Another approach (way more easier) would be adding a RadialForceComponent and fire it when you want to destroy something:
472+
473+
```py
474+
# get a reference to the RadialForceComponent
475+
self.radial_force = self.uobject.get_owner().get_actor_component_by_type(ue.find_class('RadialForceComponent'))
476+
477+
# fire it !
478+
self.radial_force.call('FireImpulse')
479+
```
480+
481+
482+
483+
Splines
484+
-------
485+
486+
Splines are another amazing UE4 feature.
487+
488+
The following component shows how to move another actor over a spline path:
489+
490+
```py
491+
class Spline:
492+
def begin_play(self):
493+
# get a reference to a spline component
494+
self.spline = self.uobject.get_owner().get_actor_component_by_type(ue.find_class('SplineComponent'))
495+
# find the length of the spline
496+
self.max_distance = self.spline.get_spline_length()
497+
self.distance = 0.0
498+
# get a reference to the actor to move (as a blueprint property)
499+
self.actor_to_move = self.uobject.get_owner().get_property('ObjectToMove')
500+
501+
def tick(self, delta_time):
502+
if self.distance >= self.max_distance:
503+
return
504+
# find the next point on the spline
505+
next_point = self.spline.get_world_location_at_distance_along_spline(self.distance)
506+
self.actor_to_move.set_actor_location(*next_point)
507+
self.distance += 100 * delta_time
508+
```
509+
759510
Blueprints integration
760511
----------------------
761512

0 commit comments

Comments
 (0)