Skip to content

Commit 250cc92

Browse files
author
rdeioris
authored
Update Subclassing_API.md
1 parent 394aac3 commit 250cc92

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

‎docs/Subclassing_API.md‎

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,77 @@ class Hero(Character):
8686
Functions and Events
8787
--------------------
8888

89+
By default any methods having the same signature of an internal virtual one (like ReceiveBeginPlay in the previous examples) will became
90+
automagically an override. Pay attention to the function annotation style for helping the blueprint system discovering the type of arguments. Except from self, any argument (or return value) without proper type will result in ignoring the argument:
91+
92+
```py
93+
import unreal_engine as ue
94+
from unreal_engine.classes import Character, PawnSensingComponent, Pawn, FloatProperty
95+
96+
class Hero(Character):
97+
98+
# you can set it from the editor as array
99+
UpSpeed = [FloatProperty]
100+
101+
# automatic override
102+
def ReceiveTick(self, DeltaSeconds: float):
103+
location = self.get_actor_location()
104+
location.z += self.UpSpeed[0] * DeltaSeconds
105+
self.set_actor_location(location)
106+
107+
# this new method will be available to blueprints
108+
def FunnyNewMethod(self, a_word: str):
109+
ue.print_string('This is a word from blueprint: ' + a_word)
110+
```
111+
112+
you can do manual override too:
113+
114+
```py
115+
import unreal_engine as ue
116+
from unreal_engine.classes import Character, PawnSensingComponent, Pawn, FloatProperty
117+
118+
class Hero(Character):
119+
120+
# you can set it from the editor as array
121+
UpSpeed = [FloatProperty]
122+
123+
# manual override
124+
def funny_receive_tick(self, DeltaSeconds: float):
125+
location = self.get_actor_location()
126+
location.z += self.UpSpeed[0] * DeltaSeconds
127+
self.set_actor_location(location)
128+
funny_receive_tick.override = 'ReceiveTick'
129+
```
130+
131+
To mark a method as 'pure' (in the Blueprint sense):
132+
133+
```py
134+
import unreal_engine as ue
135+
from unreal_engine.classes import Character
136+
137+
class Hero(Character):
138+
139+
# this new method will be available to blueprints
140+
def FunnyNewMethod(self, a_word: str):
141+
ue.print_string('This is a word from blueprint: ' + a_word)
142+
FunnyNewMethod.is_pure = True
143+
```
144+
145+
or static:
146+
147+
```py
148+
import unreal_engine as ue
149+
from unreal_engine.classes import Character
150+
151+
class Hero(Character):
152+
153+
# this new static method will be available to blueprints
154+
def FunnyStaticMethod():
155+
ue.print_string('I am a static method')
156+
FunnyNewMethod.is_static = True
157+
```
158+
159+
89160
Reloading
90161
---------
91162

0 commit comments

Comments
 (0)