Enemy rigging and coding?

I have this test enemy, and I can’t seem to use logic to make the gun fire and all…any ideas why?
thanksEnemy.blend (167 KB)

he is walking in circles shooting

yeah I know, because it used to be finding the player, but there is no player, so I just him run in circles :stuck_out_tongue:

I just want to know if
A: This is the correct rig/logic
B: why the logic isn’t making the gun fire

ok, so I think you need to check out the steering actuator, and setting it’s target with a ray.

if he is steering to a target, chances are his ray(gun) can aim down that line.

Ray[Player]-----python


import bge

cont=bge.logic.getCurerentController()
own=cont.owner
P=own.parent
sens=cont.sensors['Ray']
actu=cont.actuator['Steering']
if sens.positive:
   P['Target']=sens.HitObject
   


p2, in Parent

if own “Target” is not equal to “Empty” (you set it to that in the logic editor)

Target !="Empty:--------python


import bge
cont=bge.logic.getCurrentController()
own=cont.owner
actu=cont.actuators['Steering']
if own['Target']!="Empty":
    Target=own.target
    if Target.invalid==False:
        actu.target=Target
        cont.activate(actu)
else:
    cont.deactivate(actu) 


Is my setup for the rig right?
The gun can’t seem to animate shooting. I have pretty much everything down already then

I use this setup


Did you see the system I posted on your end object thread?

Yep, thanks :slight_smile:
hopefully I’ll remember next time I make a game

you should be able to parent your gun to the “Gun_1” etc
and then use always copy property (Fire)

always action property fire

(and copy your gun animations into my system)