Skip to content

Commit 62a03e3

Browse files
author
Roberto De Ioris
authored
Update AsyncIOAndUnrealEngine.md
1 parent 9156d84 commit 62a03e3

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tutorials/AsyncIOAndUnrealEngine.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,32 @@ Want to integrate an HTTP server into UE ? doable. Want to wait for a redis pubs
9393

9494
## Adding an asyncio loop engine in the UE4 core
9595

96+
We will start by adding a new (pretty simple) module to our project (call it ue_asyncio.py):
97+
98+
```python
99+
import asyncio
100+
import unreal_engine as ue
101+
102+
loop = asyncio.new_event_loop()
103+
104+
def ticker_loop(delta_time):
105+
try:
106+
loop.stop()
107+
loop.run_forever()
108+
except Exception as e:
109+
ue.log_error(e)
110+
return True
111+
112+
113+
ticker = ue.add_ticker(ticker_loop)
114+
```
115+
116+
Do not run this module, it will be just the 'hub' the other parts of our project will connect too.
117+
118+
Basically when you first import this module a new 'ticker' will be registered into Unreal Engine. A ticker is a function that periodically 'ticks'. In this case Unreal Engine will use this ticker function to wake up the asyncio loop engine to manage all of the coroutines registered to it.
119+
120+
Let's start with the previous timer example:
121+
96122
## asyncio in your actors
97123

98124
## Additional 'transient' loop engines

0 commit comments

Comments
 (0)