0
$\begingroup$

is it possible to add an object inside the game engine with upbge 3.X.X while having game physics work properly ? What I'm doing is:

patch = bpy.data.objects['Patch1']

for i in range(4):
    for j in range(4):
        if i or j:
            copy = patch.copy()
            copy.data = patch.data.copy()
            bpy.context.collection.objects.link(copy)
            copy.location = (i*256, j*256, 0)

This is connected to an 'always' sensor set on tap and does add my patches of ground as expected, but there are no physics and the player goes through the objects. I tried adding

copy.game.physics_type = 'STATIC'

But this doesn't sort my issue.

$\endgroup$
2
$\begingroup$

you have to use own.scene.convertBlenderObject(bpy_object) to wrap it in a KX_Object / convert its logic

$\endgroup$
2
  • $\begingroup$ Hi, thanks for the post. This site is not a regular forum, answers should be substantial and thoroughly explain the solution and required workflow. One liners and short tips rarely make for a good answer. If you can edit your post and provide some more details about the procedure and why it works feel free to restore it, otherwise it may be deleted or converted into a comment. Perhaps add a few images illustrating the workflow and final results. See How do I write a good answer? $\endgroup$ Apr 30 at 12:25
  • $\begingroup$ This is what I found out eventually. There is also the call reinstancePhysicsMesh() that can come in handy if modifying the geometry in game. $\endgroup$
    – Yvain
    May 2 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.