Closed Tibo669 closed 7 years ago
Are you using a threaded build ?
Does the following class (mapped to PyActor) works:
class Spawner:
def begin_play(self):
self.uobject.enable_input()
self.uobject.bind_pressed_key('X', self.spawn)
def spawn(self):
new_actor = self.uobject.actor_spawn(ue.find_class('PyActor'), FVector(0, 0, 0), FRotator(0, 0, 90))
Yes I'm using a threaded build.
Your class works fine, it also works fine when I do :
class SuperHero:
def begin_play(self):
ue.log('Begin Play on Hero class')
self.uobject.enable_input()
self.uobject.bind_key('K', ue.IE_PRESSED, self.spawn)
def spawn(self):
ue.log("Spawned")
new_actor = self.uobject.actor_spawn(ue.find_class('PyActor'), FVector(0, 0, 0), FRotator(0, 0, 90))
But UE still crashes when called from an other function inside SuperHero. The log only shows : [2016.10.04-19.24.26:412][452]LogPython: Spawned
Remove threading support, unfortunately an optimization we have in the PyActor constructor causes a deadlock. I am still unsure if investing in threading support is a good idea. It introduces lot of performance implications and complexities. I leave the issue opened as the fix is pretty easy (albeit it wil lrequire to disable the optimization when threading is enabled)
Latest version removed the python initializiation out of the constructor. This should support object spawning in any part of the code
Can we close it ?
Yes thank you for the quick fix. Works fine for me now
@rdeioris I am using multithreading to Spawn an Blueprint Actor and Unreal Engine is crashing suddenly when the spawn function called.
Hi,
I'm having an issue when spawning new actors. The code works fine when inside the function begin_play, but when called from an other function it just crashes UE without explanation.
I'm new to UE so maybe I haven't completely understood how it should work...
Here is the code I use :
new_actor = self.ue_object.actor_spawn(ue.find_class('PyActor'), FVector(0, 0, 0), FRotator(0, 0, 90))
Thank you