How head_shot object children can kill the parented object correctly?

HERE HAVE A VIDEO 1 working with 2 raycasts and 2 codes code 1 to body end only object hited and code 2 to end box_head hitobject but dont end the body all zombie where box_head removed

and VIDEO 2 using 1 raycast only with same property in case health_m with value 100 to body_box and valuer 25 to head_box.Have a code too.its work for shot in first object in to the scene but if shot in second or third… not work please look video 2.

I made all with python shot to body and head of enemy

but only body working cause head_box is a parent of body_box

IN video when i shot in head of 2nd enemy kill the first or endObject() the frist its wrong

Video 1 - 2 raycasts

https://youtu.be/Zb68bP4oiUg

the code use ray_cast for just kill hitobject not anothers same in scene

code for body:

#RAYTEST  if Ray_test.positive:
    hitobject = Ray_test.hitObject
    own["prop"] = hitobject.name    # get object name 

  
if Ray_test.positive and Glockflare.positive and gunspawn['equiped'] == 2  or Ray_test.positive and M24flare.positive and gunspawn['equiped'] == 1:
   # own.sendMessage('bullet_impact')
    #damage enemy sound
   # aud.device().play(enemy_damage)
   # if Zstopsound.positive == False:
        
        hitobject = Ray_test.hitObject
        
        
        if hitobject["Count_Bullet2"] == 0:
            hitobject["Count_Bullet2"] = 1
                                    
                    
        if hitobject["health_m"] < 100:
            hitobject.sendMessage('flashzombie')
        
            aud.device().play(enemy_damage)
        #c.activate(DecLive3)
            hitobject.sendMessage('Bullet_Impact3')
        
        if hitobject["health_m"] > 0:
            hitobject["health_m"] -= 25
           # render.drawnLine(own.worldPosition, ZombieCollide2REPLICATE.worldPosition, [1,0,0])
        else:
           # hitobject.endObject()
            own.sendMessage('ZombieLive3')
            zombie_to_doll = scene.objects['ZombieCollide2REPLICATE']  its body_box
            hitobject.endObject() # its head_box hit
            spawnpointdoll = scene.addObject('Emptydoll', own, 0)
            spawnpointdoll.worldPosition.x = hitobject.worldPosition.x
            spawnpointdoll.worldPosition.y = hitobject.worldPosition.y
            spawnpointdoll.worldPosition.z = hitobject.worldPosition.z - round(random.uniform(2.3, 3.0), 1)
            print("z pos ragdoll: " ,round(random.uniform(2.3, 3.0), 1))
            spawnpointdoll.worldOrientation = hitobject.worldOrientation
            
            own.sendMessage('test')

its work for body but i made new raycast to head head is child of body,how can acess when shot in head kill only body with hited head_box?

code for head_box parented to body_box

if Ray_new_hshot.positive:   
             hitobject_head = Ray_new_hshot.hitObject
    
    
             own["prop"] = hitobject_head.name
    
    
# Head Shot with GLOCK Ray Message to ZombieCollide2
if Ray_new_hshot.positive and Glockflare.positive and gunspawn['equiped'] == 2:
    #damage enemy sound
   # aud.device().play(enemy_damage)
   # if Zstopsound.positive == False:
   
  
    aud.device().play(enemy_damage)
    #c.activate(DecLive)
    own.sendMessage('Bullet_Impact3') #zombie_collide2
    own.sendMessage('Head_Shot3_glock_new') #zombie_collide3 Killed by 1 head shot
    own.sendMessage('flashzombie')
    own.sendMessage('ZombieLive3')
    
    hitobject_head = Ray_new_hshot.hitObject
    if hitobject_head["health_head"] < 100:
        hitobject_head.sendMessage('flashzombie')
        
        aud.device().play(enemy_damage)
        #c.activate(DecLive3)
        hitobject_head.sendMessage('Bullet_Impact3')
        
    if hitobject_head["health_head"] > 0:
        hitobject_head.endObject() # working for head_box
        zombie_to_doll = scene.objects['ZombieCollide2REPLICATE']# not working for body_box kill the first body_box object if have 2 or more same objects
        
         zombie_to_doll.endObject() ]# not working for body_box kill the first body_box object if have 2 or more same objects and not endObject anymore objects
       
                
        own.sendMessage('test')
        
        hitobject_head["health_head"] -= 100

head_box is a parent of body_box if help for pass properties to 2 raycast or work with one global variable if possible help me. working with hitobject

VIDEO 2 - 1 RAYCAST

code with 1 raycast for 2 objects

if hitobject["health_m"] > 0:                 # HERE not working head_box   see video 2
            hitobject["health_m"] -= 25
            
            if own["prop"] == 'head_shot3_NEW':   # head_box name got it           
                hitobject.removeParent()       # remove parent of box
                # get a list of objects in scene
                objList = scene.objects


                # get the object named Cube from the list
                body = objList["ZombieCollide2REPLICATE"]


                # get the object named Suzanne
                head = objList["head_shot3_NEW"]
                
                # make inverse a body child of head, combine shapes, no ghost
                body.setParent(head, 1, 0)
                hitobject.endObject()
                spawnpointdoll = scene.addObject('Emptydoll', own, 0)   # added ragoll to empty in position of hitobject
                spawnpointdoll.worldPosition.x = hitobject.worldPosition.x
                spawnpointdoll.worldPosition.y = hitobject.worldPosition.y
                spawnpointdoll.worldPosition.z = hitobject.worldPosition.z - round(random.uniform(5.3, 6.0), 1)
                print("z pos ragdoll: " ,round(random.uniform(5.3, 6.0), 1))
                spawnpointdoll.worldOrientation = hitobject.worldOrientation
     
                
           # render.drawnLine(own.worldPosition, ZombieCollide2REPLICATE.worldPosition, [1,0,0])
        else:   # HERE all fine working for body
           # hitobject.endObject()
            zombie_to_doll = scene.objects['ZombieCollide2REPLICATE'] # its body_box
            hitobject.endObject() # its body_box
            spawnpointdoll = scene.addObject('Emptydoll', own, 0)
            spawnpointdoll.worldPosition.x = hitobject.worldPosition.x
            spawnpointdoll.worldPosition.y = hitobject.worldPosition.y
            spawnpointdoll.worldPosition.z = hitobject.worldPosition.z - round(random.uniform(2.3, 3.0), 1)
            print("z pos ragdoll: " ,round(random.uniform(2.3, 3.0), 1))
            spawnpointdoll.worldOrientation = hitobject.worldOrientation
            
            own.sendMessage('teste')

any sugestion how for head_shot kill all zombie only where raycast positive?

I see this post
BluePrintRandom
21-Sep-15, 21:28

Dont use hitboxes for the head etc, just use 1 for the actor, and look up tags parented to each bone/area

BluePrintRandom

21-Sep-15, 21:28
what this does is look up which HitTag is closest.

I,m using a raycast from logic bricks in my camera of player try adpat your code but no have sucess.can use your code with a raycast camera?

How can i create this list? the area[head,chest,pelvic] ? its 3 objects in one group? its one object only?

this thecknic will correct kill the only hitobject but head with one shot type health = 0
and shot in body cause damage?

I need just a body or chest and head

[SOLVED] I just thinking how save a value of one property created in script to one file without any relation with head_box or body_box the find solution "using save/load property adapted(not module save/load) directly in to the script working in raycast statment.See in video now.Working good.Long Life to BGE!!!