How to do physics for a virtual creature (robot) joints.

I need to create something like this





I tried using bones but collision physics didn’t work out at all. I also tried Rigid Body Joint constraint and it looked better but it wouldn’t keep objects attached strongly enough to each other and I also don’t know how flex joints through python or logic bricks. Do you guys have any suggestions

search for ragdoll

I’m not making a doll. It must be able to walk not just fall like a dead. Besides all tutorials I found are done in Blender Render while I’m working in Blender Game

I’m not making a doll. It must be able to walk not just fall like a dead. Besides all tutorials I found are done in Blender Render while I’m working in Blender Game

it seems like youre misunderstanding that the 3d models in the video use complex physics to control their joints, when actually all of the motion done in those animations is just animation, pure and simple, done with keyframes. the keyframes are then controlled by the action actuator.

also, it seems like you misunderstand that ragdoll does not necessarily mean it just ‘drops dead’. it means that all the joints and bones are going to follow the source of velocity within the object. so if you wiggle an object with ragdoll physics, its going to appear to do a ‘slither’ like the snake creature in the first video.

search how to make a ragdoll

All tutorials I found were about dolls that literally ‘drop dead’. I found only one that does what I want but it’s not even a tutorial it’s just a demo with big python script that I don’t understand

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()

t += 0.05</i>

Ragdoll

parts
Physics Bone Rig = RagBones = Rigid body ragdoll physics rig
Gfx Armature = rigged actor, uses copy rotation in each bone targeting Ragbones

Gfx armature is normaly parented to the root Ragbone.
Ragbones use rigid body joints, to form a ragdoll from many rigid bodies.

and it can get more complex from here
(this method will never ’ pull apart’)

Triangle mesh physics shapes on terrain and ragdolls don’t get along at high speed, its best to use many convex hulls or spimple bounds like sphere cube etc.
(if you want objects not to tunnel*)

another method is to raycast forward from points in the actor along the linear velocity, so if the actor is going fast enough to teleport through a triangle mesh, the ray still intersects, it’s a form of Continious collision detection.

CCD etc are only necessary if you will be flinging things at very high speeds*

How can I parent single Gfx Armature to many different parts of RagBone?

How can I parent single Gfx Armature object to many different parts of RagBone?

I used python to copy orientation from bones to cubes because constraints do not work for some reason, they just have no effect whatsoever. But there are still horrible problems. here’s the project
http://www.filedropper.com/worm

Attachments



The armature is parented to the ‘Root’ object ragbone (the only ragbone that has no rigid body joints inside of it

the bones move by using copy rotation constraint in each bone, targeting a ragbone

The thing is, I don’t want ragbone to move a bone, I need bones to move ragbones and I figured out the way to do it

@AlexAzazel

Try updating the objects position together, it works for me


import bge

def main():
    scene = bge.logic.getCurrentScene()

    cube1 = scene.objects["BP-bone.000"]
    cube2 = scene.objects["BP.000"]
    cube2.worldPosition = cube1.worldPosition
    cube2.worldOrientation = cube1.worldOrientation

    cube1 = scene.objects["BP-bone.001"]
    cube2 = scene.objects["BP.001"]
    cube2.worldPosition = cube1.worldPosition
    cube2.worldOrientation = cube1.worldOrientation
    
    cube1 = scene.objects["BP-bone.002"]
    cube2 = scene.objects["BP.002"]
    cube2.worldPosition = cube1.worldPosition
    cube2.worldOrientation = cube1.worldOrientation

btw blender has 2 types of constraints, bone constraints and object constraints

Normally, armature bones only animate the model and has nothing to do with motion or physics in general except when you use the armature bone constraints to copy transformation from a ragdoll(rigidbody objects) not unlike your current setup but with python to switch it on and off instead

I’ll post a quick blend test when I find the time

Worm_ragdoll_control.blend (492 KB)

Here is a ragdoll switch with bone constraints, press W and ragdoll physics will kick in

The logic here is the script(copyRot) that updates your ragdoll position/orientation will switch off and simultaneously switch on the bone constraints so that each bone will copy transformation of the rigid bodies pos/ori it is assigned

Turns out I don’t need bones at all and all the ragdoll tutorials were irrelevant. All I needed to create crawling creatures was to connect bunch of cubes with custom Rigid Body Joints (Generic 6 Degree of Freedom), place their pivot pints correctly (making corners of cubes touch and placing pivot there is the best) and apply torque on them through python to move them. That’s all
/uploads/default/original/4X/7/3/4/734564772514d7fbb54af70cdca8de0e478a21ff.blendstc=1

Attachments

CrawlingMonkeys.blend (547 KB)