I am making my Ai for the Blender Game Competition. I scripted it all myself, but its not quite working yet. I show the script below and a .blend.
Situation :
The script tells the Guard to walk if “random_prop” is 1 or stand idle if “random_prop” is 2. But all he does is stand animation, but moves forward as if he were walking.
Uber embarrassment :o
Scripts :
import random
import Mathutils as MT
cont = GameLogic.getCurrentController()
own = cont.owner
own["random_prop"] = int(MT.Rand(1, 2))
i_see_you = cont.getSensor("see_player")
player_right = cont.getSensor("right")
player_left = cont.getSensor("left")
stop_turn = cont.getSensor("stop_turn")
Patrol = cont.getActuator("MoveAround")
Idle = cont.getActuator("Idle")
mes_patr_send = cont.getActuator("Patrol_Armature")
mes_idle_send = cont.getActuator("Idle_Armature")
turn_left = cont.getActuator("Turn_left")
turn_right = cont.getActuator("Turn_right")
rotation = [ 0.0, 0.0, 0.1]
def roamer() :
cont.activate(Patrol)
cont.activate(mes_patr_send)
def idle() :
cont.activate(Idle)
cont.activate(mes_idle_send)
def attack() :
if player_left.isPositive:
own.applyRotation( rotation, True)
if player_right.isPositive:
cont.activate(turn_right)
if own["random_prop"] == 1 :
roamer()
if own["random_prop"] == 2 :
idle()
if i_see_you.isPositive :
attack()
and for the Armature :
import random
import Mathutils as MT
cont = GameLogic.getCurrentController()
own = cont.owner
mes_patr_receive = cont.getSensor("Patrol_AI")
mes_idle_receive = cont.getSensor("Idle_AI")
walk = cont.getActuator("Walk")
stand = cont.getActuator("Stand")
attack = cont.getActuator("attack_Armarture")
def roamer() :
cont.activate(walk)
def idle() :
cont.activate(stand)
def attack():
cont.activate(attack)
if mes_patr_receive.isPositive :
roamer()
if mes_idle_receive.isPositive :
idle()
Please help. Thanks. And if there is anything else that could be fixed or improved, please explain it, this is my first Ai script:o.
.blend
W, S, A, D move
Q to add Gaurd
and if u want to see the Gaurd setup, it is on Layer 6 on the second row ( If that makes sense:confused:).
Thanks in advance.