Beispiel #1
0
    def __init__(self,
                 world: BulletWorld,
                 entity: Entity,
                 radius=1,
                 height=2,
                 name='Player',
                 **opts) -> None:
        super().__init__(BulletCapsuleShape(radius / 2, height / 2, 1),
                         radius / 2, name)
        self.np = application.base.render.attachNewNode(self)

        if entity.parent:
            self.np.reparent_to(entity.parent)

        rotation = Vec3(0, 0, 0)
        if None in rotation:
            hpr = entity.getHpr()
            for x in range(len(hpr)):
                rotation[x] = hpr[x]
        self.np.setHpr(rotation)

        self.np.setPos(entity.x, entity.y, entity.z)
        entity.reparent_to(self.np)

        world.attachCharacter(self)

        self.__fall_speed = None
        self.__jump_speed = None
        self.__max_jump_height = None

        for x in opts:
            setattr(self, x, opts[x])
Beispiel #2
0
    def __init__(self, world:BulletWorld, entity:Entity, shape, name, rotation):
        super().__init__(name)

        self.addShape(shape)
        self.np = application.base.render.attachNewNode(self)

        world.attachGhost(self)

        if entity.parent:
            self.np.reparent_to(entity.parent)
        
        if None in rotation:
            hpr = entity.getHpr()
            for x in range(len(hpr)):
                rotation[x] = hpr[x]
        self.np.setHpr(Vec3(*rotation))
        
        self.np.setPos(entity.x, entity.y, entity.z)
        entity.reparent_to(self.np)