Ejemplo n.º 1
0
    def create_object(self):
        from panda3d.core import Filename, NodePath, BitMask32
        from direct.actor.Actor import Actor
        from panda3d.bullet import BulletRigidBodyNode, BulletCapsuleShape

        from game_system.resources import ResourceManager
        f = Filename.fromOsSpecific(ResourceManager.get_absolute_path(ResourceManager["TestAI"]["lp_char_bs.egg"]))
        model = Actor(f)

        bullet_node = BulletRigidBodyNode("TestAIBulletNode")
        bullet_nodepath = NodePath(bullet_node)

        bullet_node.set_angular_factor((0, 0, 1))

        shape = BulletCapsuleShape(0.3, 1.4, 2)
        bullet_node.addShape(shape)
        bullet_node.setMass(1.0)

        model.reparentTo(bullet_nodepath)
        model.set_hpr(180, 0, 0)
        model.set_pos(0, 0, -1)

        bullet_nodepath.set_collide_mask(BitMask32.bit(0))
        bullet_nodepath.set_python_tag("actor", model)

        return bullet_nodepath