| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 394aac3 commit 250cc92
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -86,6 +86,77 @@ class Hero(Character): | |||
| 86 | 86 | Functions and Events | |
| 87 | 87 | -------------------- | |
| 88 | 88 | ||
| 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 | + | ||
| 89 | 160 | Reloading | |
| 90 | 161 | --------- | |
| 91 | 162 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments