Skip to content

Commit fd2a809

Browse files
author
Roberto De Ioris
committed
added first example
1 parent f217f65 commit fd2a809

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

examples/editor_scripting001.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import unreal_engine as ue
2+
from unreal_engine import FVector
3+
4+
from unreal_engine.classes import Actor, Pawn, Character, ProjectileMovementComponent, PawnSensingComponent, StaticMesh
5+
from unreal_engine.classes import StaticMeshComponent, StaticMeshActor, PointLightComponent
6+
7+
world = ue.get_editor_world()
8+
9+
for i in range(0, 10):
10+
new_pawn = world.actor_spawn(Pawn, FVector(0, 0, i * 1000))
11+
new_pawn.set_actor_label("FooBarPawn {0}".format(i))
12+
projectile = new_pawn.add_actor_component(ProjectileMovementComponent, 'Projectile Movement')
13+
projectile.InitialSpeed = 173.0
14+
projectile.MaxSpeed = 999.9
15+
16+
for i in range(0, 10):
17+
new_character = world.actor_spawn(Character, FVector(i * 100, 0, i * 1000))
18+
new_character.set_actor_label("FooBarCharacter {0}".format(i))
19+
sensing = new_character.add_actor_component(PawnSensingComponent, 'Ears')
20+
21+
# add a cone
22+
cone = world.actor_spawn(Actor)
23+
cone.set_actor_label('A Cone')
24+
cone_mesh = cone.add_actor_component(StaticMeshComponent, 'Cone')
25+
cone_mesh.StaticMesh = ue.load_object(StaticMesh, '/Engine/BasicShapes/Cone')
26+
cone.InitialLifeSpan = 30.0
27+
28+
# add a better cone
29+
cone2 = world.actor_spawn(StaticMeshActor)
30+
cone2.StaticMeshComponent.StaticMesh = ue.load_object(StaticMesh, '/Engine/BasicShapes/Cone')
31+
cone2.set_actor_label('A Better Cone')
32+
33+
# create a new bleprint
34+
bp = ue.create_blueprint(Pawn, '/Game/SuperEvilPawn')
35+
ue.add_component_to_blueprint(bp, PawnSensingComponent, 'Eyes')
36+
point_light = ue.add_component_to_blueprint(bp, PointLightComponent, 'Light')
37+
point_light.Intensity = 9999.9
38+
ue.blueprint_add_member_variable(bp, 'SightPower', 'float')
39+
ue.blueprint_set_variable_visibility(bp, 'SightPower', False)
40+
41+
ue.compile_blueprint(bp)
42+
43+
super_evil_pawn = world.actor_spawn(bp.GeneratedClass)
44+
super_evil_pawn.set_actor_label('Super Evil Pawn')
45+
super_evil_pawn.SightPower = 2217.30
46+
47+
ue.editor_save_all()
48+
49+

0 commit comments

Comments
 (0)