Hi,
although the above example is an ideal chance to start understanding how a script works the same can be managed with Logic Bricks only too. ![]()
And be simplified. No need to use different states.
I wasn’t sure,
Why head on the cube, surely it is the body? So shoot the cube bodyhit is the word for that. I saw the example for the AI character, and I just thought that was the way to go about that.
That example is to use the knife, not a gun? I would need a gun for that, as that cube is the basis for a new AI. I wanted to keep it a bit more simple compared to the main one, just for ease of use.
What is “that example”? You must be more clear in your questions.
Both examples work with guns and knife.
Let’s concentrate on the “only bricks”-solution. That is the most simple solution.
There are 2 Message Sensors.
If the player shoots and hits the cube, he will send a message with subject “hit”.
If the player uses the knife and hits the cube, he will send a message with subject “knife”
When the Message Sensors get one of these messages they will trigger the controller that will add “-1” to the health property.
Yes, the headhit could be removed from the script and the Sensors brick deleted. You can try to do it.
I think it works, but the cube seemed to vanish, after I had shot it many times, but I am not sure if it removed instant, I went to see the Ai I had removed, so I went back up the stairs, and it wasn’t there.
My video shows what is or isn’t working.
Does the go property also required on the Ai cube, I don’t think so.
You are incredible! ![]()
I see what is wrong on your try but I won’t tell you.
If you manage to build your bricks like in my picture it will work.
Hint:
- check And-Controller states
- why do you add 1 health?
- Are the Actuator names really correct? state3 is not the same as State3
- which Always Sensor has the 3 dots enabled?
- You are your teacher
Please look above. I posted a solution without Code with a nice image.
If you manage to build your bricks like in my picture it will work.
And don’t forget: Never look at the Console for errors because this is only for nothing.
I’m sure you will master it. Because you want. Please post a picture of your working bricks.
I did try and do what you’ve put together, but nothing changes?
I also forgot, using key 7 I wanted to load the item to use, so it would work similar to a knife, just animated a little for effect. The chain item. I never got it to work. I don’t know. That was my first goal, when I tried this edit in April.
I never do look at the console…
I’m not that well versed in all of blender.
The collision works of the AI with the player, to cause damage, but not too well, but the player doesn’t end as a result of too much collision, knife guy finishes the player off. Ha!
in Change.py, that was where I tried to add 7 load chain onto player’s hands. It never loaded. I had to edit it a lot to make it stable for the game. But yes, I am guessing the knife code will work perfectly for that, using the bricks or code. Bit of both.
import bge
cont = bge.logic.getCurrentController()
scene = bge.logic.getCurrentScene()
own = cont.owner
equipped = own['equipped']
target = own['target']
timer = own['timer']
change = own['change']
reload = own['reload']
Grenades = own['Grenades']
Smoke = own['Smoke']
shoot = own['shoot']
collide = cont.sensors['cutscene']
#animations
down_m24 = cont.actuators['downm24']
downGlock = cont.actuators['downGlock']
upm24 = cont.actuators['pickupm24']
upGlock = cont.actuators['pickupGlock']
downGren = cont.actuators['down_Gren']
upGren = cont.actuators['pickup_Gren']
Sdown = cont.actuators['Sdown']
Sup = cont.actuators['Sup']
Kdown = cont.actuators['knifedown']
Kup = cont.actuators['knifeup']
opendoor = cont.actuators['opendoor']
self = scene.objects[own.name]
movement = scene.objects['player']
#sets change == True
if own['target'] != own['equipped'] and reload == False and shoot == True or own['equipped'] == 0 or own['target'] == 6:
self['change'] = True
elif own['target'] == own['equipped']:
self['change'] = False
#timer
if change == True and timer < 30 and movement['door'] == False:
own['timer'] += 1
if change == True and movement['door'] == True and timer < 45:
own['timer'] += 1
#putting down weapon
if equipped == 0 and change == True and timer == 0:
cont.activate(downGlock)
if equipped == 1 and change == True and timer == 0:
cont.activate(down_m24)
if equipped == 2 and change == True and timer == 0:
cont.activate(downGlock)
if equipped == 3 and change == True and timer == 0:
cont.activate(downGren)
if equipped == 4 and change == True and timer == 0:
cont.activate(Sdown)
if equipped == 5 and change == True and timer == 0:
cont.activate(Kdown)
if equipped == 7 and change == True and timer == 0:
cont.activate(Kdown)
#ends old weapon + animation
if timer == 15 and change == True and equipped == 0:
cont.deactivate(downGlock)
if timer == 15 and change == True and equipped == 1:
own.sendMessage("endm24")
cont.deactivate(down_m24)
if timer == 15 and change == True and equipped == 2:
own.sendMessage("endglock")
cont.deactivate(downGlock)
if timer == 15 and change == True and equipped == 3:
own.sendMessage("endGren")
cont.deactivate(downGren)
if timer == 15 and change == True and equipped == 4:
own.sendMessage("endSmoke")
cont.deactivate(Sdown)
if timer == 15 and change == True and equipped == 5:
own.sendMessage("endKnife")
cont.deactivate(Kdown)
if timer == 15 and change == True and equipped == 7:
own.sendMessage("endchain")
cont.deactivate(Kdown)
#spawn new weapon
if timer == 15 and change == True and target == 1:
scene.addObject('m24', own, 0)
if timer == 15 and change == True and target == 2:
scene.addObject('Glock', own, 0)
if timer == 15 and change == True and target == 3:
scene.addObject('Grenade', own, 0)
if timer == 15 and change == True and target == 4:
scene.addObject('smoke', own, 0)
if timer == 15 and change == True and target == 5:
scene.addObject('knife', own, 0)
if timer == 15 and change == True and target == 7:
scene.addObject('chain', own, 0)
#picking up weapon
if timer > 15 and timer < 30 and change == True and target == 1:
cont.activate(upm24)
if timer > 15 and timer < 30 and change == True and target == 2:
cont.activate(upGlock)
if timer > 15 and timer < 30 and change == True and target == 3:
cont.activate(upGren)
if timer > 15 and timer < 30 and change == True and target == 4:
cont.activate(Sup)
if timer > 15 and timer < 30 and change == True and target == 5:
cont.activate(Kup)
if timer > 15 and timer < 30 and change == True and target == 7:
cont.activate(Kup)
if timer > 15 and timer < 45 and change == True and movement['door'] == True and target == 6:
cont.activate(opendoor)
#open sesame
doorsound = cont.actuators['doorsound']
if timer == 30 and change == True and movement['door'] == True and target == 6:
select = collide.hitObjectList[0]
own.sendMessage("opendoor", "", str(select))
cont.activate(doorsound)
#resetting properties
if timer == 30 and change == True and own['equipped'] != own['target'] and movement['door'] == False:
own['equipped'] = own['target']
own['timer'] -= 31
cont.deactivate(upm24)
cont.deactivate(upGren)
cont.deactivate(upGlock)
cont.deactivate(Sup)
cont.deactivate(Kup)
#resetting after cutscene
if timer == 45 and change == True and movement['door'] == True and own['equipped'] != 6:
own['equipped'] = own['target']
movement['door'] = False
movement['control'] = True
movement['cutscene'] = 0
self['timer'] = 0
own.sendMessage("restorecontrol")
cont.deactivate(opendoor)
own['target'] = 2
#intial weapon selection
if equipped == 0:
self['target'] = 2
I am guessing when it loaded, it would use the similar animation of kup and kdown or something.
I am not sure what the position is with that. Could I simply just use the existing AI’s cube so headshot and bodyshot. One below and one above.
I did use the cube for movement, and then tried to add the bodyshot sensor, for a new AI, but it doesn’t work out too well. Can the bodyshot object so the middle one be used for both for a new AI? Do all three need to be use, because a bigger AI has all of them?
Armature is parent of the model. Then cube must be parent of the model object, and then bodyshot is child or something else.
Normally one cube is enough.
I tried again,
I edited the AI.
The AI doesn’t seek the player, not sure why this is.
I then simply tried to see if I could duplicate the wall and door, and placed it somewhere, included the open door object and trigger. The animation works but properly, but the doesn’t open once the scene is played only the arm movement and sound once.
The AI cube does actually damage the player now. But it didn’t remove itself, I notice this happened with the new AI using the duplicate cubes from the existing AI. ![]()
Hi,
why do you have the health2.py set to state2?
Do you understand how states work?
From your previous video it looks like the cube isn’t the parent of the armature but the child.
Here again (!!! see above!) is a solution for your cube without Python, hit sensors or different states.
On the left the properties. In the middle the logic bricks. On the right the physic settings.
BTW: Learn to look at the console for error messages. please!
I think Dynamic physics work better.
The bknife and bodyhit Message sensors better set to “Or” if you combine them. Or give each his own “And”-controller.
The Message “Pdie” alone does nothing. You also must send “Phit”.
Also this all only works if you are eqipped with the weapons.!!!
All the Message Sensors for Filters are redundant. Or did you remove them from the Camera?
The will only have effect when you use the menu and enable them with the mouse.
If you want the filters to always be enabled then you must replace the Message sensors with “Always”-Sensors.











