def __init__(self): try: self.SetActorTickEnabled(True) self.SetRootComponent(self.CreateUStaticMeshComponent('body')) self.body = uepy.UStaticMeshComponent.Cast(self.GetRootComponent()) self.body.SetStaticMesh(DOOR_MESH) except: logTB()
def __init__(self): try: self.SetActorTickEnabled(True) self.SetRootComponent(self.CreateUStaticMeshComponent('mesh')) self.mesh = uepy.UStaticMeshComponent.Cast(self.GetRootComponent()) self.mesh.SetStaticMesh(couch) except: logTB()
def __init__(self): try: self.SetActorTickEnabled(True) self.SetRootComponent(self.CreateUStaticMeshComponent('body')) self.body = uepy.UStaticMeshComponent.Cast(self.GetRootComponent()) self.body.SetStaticMesh(BODY_MESH) self.body.SetRelativeScale3D(FVector(0.25, 0.25, 0.25)) self.arm = uepy.UStaticMeshComponent.Cast(self.CreateUStaticMeshComponent('arm')) self.arm.SetStaticMesh(ARM_MESH) self.arm.AttachToComponent(self.body) self.arm.SetRelativeLocation(FVector(0,0,250)) self.created = time.time() except: logTB()
def __init__(self): # NOTE: (pay attention, cuz it took me half a day to figure this out) # we use the polymorphic_type_hook in uepy.h to make pybind11 aware of engine types so that, given a UObject pointer, it can perform # automatic downcasting. Unfortunately, we can't use game-specific types in there (in part because that table is declared in uepy and isn't # easily movable into our game module). When we create new UClass objs for our py subclasses, the constructor passes the engine obj to this # __init__ function, but since the constructor is generic code, all it has at that point is a UObject pointer, so engineObj gets passed to us # as such, but we need pybind to instead downcast it to e.g. ACActor in this case, but there's no way for the constructor code to know how to # do that because it's all template-based. So instead we receive an engineObj here and then require the game module to expose a casting API # so that we can get pybind11 to send us a properly downcasted variable, which we store for future calls. try: self.SetActorTickEnabled(True) r = 1000 self.pos = [r*random.random()-r/2, r*random.random()-r/2, 0*random.random()] self.angle = 0 self.speed = random.random() * 20 self.angleTarget = random.random() * 2 * math.pi - math.pi self.dx = 0 self.dy = 0 self.SetRootComponent(self.CreateUStaticMeshComponent('mesh')) self.mesh = uepy.UStaticMeshComponent.Cast(self.GetRootComponent()) self.mesh.SetStaticMesh(couch) except: logTB()
def DoSomething(self, i): try: log('Do something!', self, i) self.SetActorRotation(FRotator(RR(0,360), RR(0,360), RR(0,360))) except: logTB()
from uepy import log, logTB import uepy try: # Add any 3rd party libs to sys.path import deps deps.Discover() except: logTB() def Init(): '''called from ue4 when this module is loaded on startup (or, in dev, when the c++ game module is recompiled''' log('main.Init called') # AVOID module-level stuff with side effects? # TODO: we need better rules around what happens at module scope vs Init (and if Init is needed at all) import myactors try: import uepy.editor import editor_spawner except ImportError: pass # not in editor def OnPreBeginPIE(): log('main.OnPreBeginPIE called') global myactors myactors = reload(myactors)