Attack AI and AI attack python code?

So the cube must be the parent of the weapon, as the arm is separate from the player, obviously.

yes, edit uh no lol, cube will be child of weapon not the parent, the weapon will be the parent.

Arm - empty parented to a arm/hand bone. weapon parented to the empty, sensor cube parented to weapon., script on sensor cube.

sensor cube: collision - python


    collision = cont.sensors['Collision']
    
    if collision.positive:
        
        hit = collision.hitObject
        
        if 'life' in hit:
            # from that point, hit is an object
            hit['life'] -= 1

            if hit['life'] < 0:
                # oh no, hit is dead!
                hit.endObject()

There is no bone, only an arm, with a weapon joined to it. And no empty. This is made it more complicated.

then simply parent the sensor cube to the arm, but put the cube over the weapon only(or if no weapons and only fists then put the cube over the fist). and if you got a separated weapon then just parent it to the weapon instead of the arm.

I have done it now, it doesn’t work properly. The weapon now or arm now goes back behind the player when left button is clicked. The arm is the parent of the cube, and the empty is a child of the arm too.

here:
melee attack.blend (535.4 KB)

w forwards, s backwards,

So both objects have the script. And the arm is sorted, but it doesn’t work properly.

As for the example w and s don’t do anything.

hmm it moves the player lol, w to walk forwards to poke the cylinder, go backwards and repeat until it’s dead.

You’ll need to see again, nothing happens here.

i did, works fine here

Well the file you sent has nothing in the brick?

Could be because I am using script and not module, but that doesn’t make sense, since i have a black screen a result with script and not module.

Well nothing happens in the file, I see your result, that does work.

Well the file you sent has nothing in the brick?

uhm as property? no. leave it blanc, script checks for life property in objects in order to remove hp, if it has none it does nothing

Tried the file again, it doesn’t work for me. The object won’t after pressing w or s.

then hit cylinder and remove the bricks and re add them, also check the physics settings of the objects.
I used upbge, and you use bge? maybe that is the problem (no clue if they have changed anything related to that) anyway not a fan of using bricks anyway, but my setup is good, you can simply recreate it in your own blend.

I use blender game engine, I don’t use upbge, that doesn’t work with my files the LIS demo.

That doesn’t solve my exact problem with the arm, now that loads by default behind the fp

So you are now using the latest independent blender build?

I recorded some clips using fraps, but they don’t play on windows 10 some codec missing what ever, and the videos won’t load on windows 7 movie maker, so I could show what the result is.

I use upbge 0.2.4

If your graphicscard does not have a recording option then OBS is the software you need.

then i guess the scaling is off(ctrl+a, apply scale, unparent it first then apply scale) or you did not turn off it 's physics.

I tried the scale, all that did was remove the texture on the weapon, still the same problem.

huh? it can’t remove a texture. it only applies the scale. If you scale something in edit mode, the scale stays at 1.0. if you scale something in object mode, the scale will in/de-crease. Apply scale in this case will set the scaling you have done in object mode to 1.0.

ctrl + A doesn’t do anything in edit mode, in object mode, I applied the scale, and that was the result after I had parented to the player and tested it.