Bpy constrain created with python work at runtime?

I wish just made copy location and copy rotation from one object to a armature pose bone but dont know.

If possible help me and tell if work bpy with runtime game for this.

In this code please look i think need just known how change mathutils object vector to target vector



import bge
import math
from math import *
import mathutils

t = 0

def rotate():
global t
# Get the whole bge scene
scene = bge.logic.getCurrentScene()
# Helper vars for convenience
source = scene.objects

# Get the whole Armature

main_arm = source.get('Armature')

ob = bge.logic.getCurrentController().owner

x = math.sin(t)
ob.channels['Bone.000'].joint_rotation = mathutils.Vector([0,0,math.tanh(-x)])
ob.channels['Bone.001'].joint_rotation = mathutils.Vector([0,0,math.tanh(x)])
ob.channels['Bone.002'].joint_rotation = mathutils.Vector([0,math.tanh(x),0])
ob.update()

for mesh follow the bone with weight p.
If you know how please help
Thanks

just already have the constraint, set to target a object with a strength of zero
[see - https://pythonapi.upbge.org/bge.types.BL_ArmatureObject.html?highlight=armature%20bge ]
and
https://pythonapi.upbge.org/bge.types.BL_ArmatureConstraint.html#bge.types.BL_ArmatureConstraint
don’t use BPY ->

use armature.constraints[‘CopyLocationName’].target = newObject

or parent a empty to the bone

always----------[python]

add property ‘Target’ that is the name of the object to target (like ‘Empty’ etc)


import bge
cont = bge.logic.getCurrentController()
own = cont.owner

target = own.scene.objects[own['Target']]
own.worldTransform = target.worldTransform

ive found that constraints dont work with added objects. setting the target didnt help either.

what did work is manually copying a localPosition to set the location of a armature channel pose. i dont think there is a way to work in world space. the armature needs to have an animation running on it(just dont animate the constrain bones), armature.update() doesnt work for added objects.

https://pythonapi.upbge.org/bge.types.BL_ArmatureChannel.html#bge.types.BL_ArmatureChannel.location

my problem is with my ragdoll. look my video

what alternative for me spawn my ragdoll on blender 2.79? my game have a lot of bugs on upbge

my problem is spawn my ragdoll friend.there have 15 bones with constrain copylocation and copyrotation target is one by one of rigid bodies objects please look my video

i try implementation kit of ragdolls but not working yet.Any simple alternative for spawn my ragdoll?The ragdoll error have a intanced group constrains not work

Please look my video constrains not work after intanced group of objects

Can create 15 empty parented with rigid bodies and use your code to all bones?

Please look my video constrains not work after intanced group of objects

Can create 15 empty parented with rigid bodies and use your code to all bones?

I find this code example to control bone with python

Please look if can adapt to my target rigidbody objects for can then spawn rigidbody objects intanced and can work?

I can’t figure out how to connect bones to an armature mesh so that I can control the armature through bones which are in turn controlled through python. I only have a code that controls bones so far

import bge
import math
from math import *
import mathutils

t = 0

def rotate():
global t
# Get the whole bge scene
scene = bge.logic.getCurrentScene()
# Helper vars for convenience
source = scene.objects

# Get the whole Armature

main_arm = source.get('Armature')

ob = bge.logic.getCurrentController().owner

x = math.sin(t)
ob.channels['Bone.000'].joint_rotation = mathutils.Vector([0,0,math.tanh(-x)])
ob.channels['Bone.001'].joint_rotation = mathutils.Vector([0,0,math.tanh(x)])
ob.channels['Bone.002'].joint_rotation = mathutils.Vector([0,math.tanh(x),0])
ob.update()

your code i got errors friend can you send me a blend file example?

please friend if you know how do it please give me a north send me a small blend file or code for just 1 bone channel skinned working with copy location and copyrotation for i reapeat to my all 15 bones on my armature for finally spawn

thanks in advance

a simple work around?

duplicate the ragdolls in the viewport,

and make them invisible on main layer

use upbge suspend physics so they don’t cost anything

then when a agent dies simply move the ragdoll in, turn visible and enable physics, and delete agent he is replacing.

YEAH is for dead zombie representation onlyI HAVE ALREADY THOUGHT IN A PALEATIVE SOLUTION WITH THAT HIS BUT I USE BLENDER 2.79 EVEN IF MY GAME LOADS THE LOT OF BUGS ON TEXTURES AND ANIMATIONS IN UPGE FOR NOW

will work on blender 2.79?May be suspend/restore dynamics?

suspend / restore dynamics and rigid body sim will help yes,

In this case i will put the rigidbody with 15 objects, armature and mesh in main active layer invisible with suspend physics

this oblects not collide not exist in game but will put empty to center of mass of object is same scale of zombie then move tho position of zombie zombie endObject() then activate the physics put all to visible.

will try on monday in my work job.i will let you after results

after this physic complete need reset a ragdoll have possibility for use in another zombie in loop?

thanks a lot

The time of total physic action is 4 secs or 240 frames then i need create a 4 copies of objects for work second by second then i will kill till 1 zombie per second without bug

The problem is make the sequence for that

hi

try if possible look my project and if possible send me example of just 1 bone deforming correctly mesh with instance group for i repeat to another 14 bones
This is my blend compressed file link
http://www.mediafire.com/file/ntaak…bie_ragdoll.7z

And normal .blend file link
http://www.mediafire.com/file/jfy3a…_ragdoll.blend

Just give 1 example of one bone spawned with constraints working and i will repeat for all 14 bones with constraints pose mode applying as rest pose.
Thanks a lot

In this code please look i think need just known how change mathutils object vector to target vector



import bge
import math
from math import *
import mathutils

t = 0

def rotate():
global t
# Get the whole bge scene
scene = bge.logic.getCurrentScene()
# Helper vars for convenience
source = scene.objects

# Get the whole Armature

main_arm = source.get('Armature')

ob = bge.logic.getCurrentController().owner

x = math.sin(t)
ob.channels['Bone.000'].joint_rotation = mathutils.Vector([0,0,math.tanh(-x)])
ob.channels['Bone.001'].joint_rotation = mathutils.Vector([0,0,math.tanh(x)])
ob.channels['Bone.002'].joint_rotation = mathutils.Vector([0,math.tanh(x),0])
ob.update()

for mesh follow the bone with weight p.
If you know how please help

Suspend/restore dynamics not work property.just made a lot of bad deformations on mesh.and without suspend get mesh is crazy movements without any control not good

Does it not work on your end ?

I’m 99% certain that I’m adding a rigged object and updating constraints with it…
I will see if I can make a test blend later today.

Post here your ragdoll spawn blend file.if worked i will send to you a credits in to my game beleive