UPBGE fighting game attack on turn

Hello everybody,
after numerous attempts and experiments to try to make one attack at a time from 3 characters/opponents I decided to ask for help,

the logic of the scene is this:
a central empty chose between 5 tipes of attacks using an integer property [R] that is changed by a random actuator and for each one set the right logic states but only if all the 3 opponents are in standing pose “STAND” (when this is true it send continue pulse to a boolean [STAND] property type LEVEL)
once added that states, only if the property [STAND] is True it runs a random that should chose between one actions of one of the opponents.

many times i run the game and the [STAND] property shakes between True and False rapidly even if i can’t see any causes, this causes a fast changing of the actions random even if it have to stop when one action is started, it ignores it so more attacks are played together by all the opponents.

LATER i tried to set a timer to trigger the attacks random (the timer is set to 0 every time an actions ends (except for stand actions) or every times all opponents are in stand pose but triggering a true pulse every 120 logic tics)
the problem still persist, the property [r] which is the integer property that choses an action still ignore to stop once one action is started, maybe the sensor that is triggering the [r] random is triggering two pulse even if it is selected TAP!

these are 3 shoots to better see what i’m saying


now characters attacks when Stime = 1
and random is triggered when Stime = 0
all work as it have to do and as i want :slight_smile:

you are making a fighting game too ? Can you show screenshots ?

it is an SFW-NSFW/18+ game, these shoots are SFW
and this was the first level, the topyc is based on the second one
it is a game for specific target so it is different from common fighting game


i like the graphics. But you reached a level of complexity you better switch to python … because it will be just more simple for your to progress :wink: Maybe ask someone on the forum ?

i’m scared to use scripts, i already tried them but i notice that many times i should spend more time writing it that linking three simple logic bricks,
i wish i could find an updated manual of the BGE module and is use in blender by the basic to the advanced,
but i ridden somewhere that scripts have to be always executed and this slows down the game!?

Depends on the script. Somethings you have to check every frame for, no way around that. This is true for logic bricks as well, try having a thousand cubes checking for a property change or collision.

My take? Your logic setup makes my head hurt. If you’re good enough at thinking to work with that and not go crazy then it’s time to stop messing around, bite the bullet and get into programming.
Not really trying to tell you what to do just thinking out loud.

i feel comfortable with logic briks also because i love to think, i’m always more using python to change things like: mist true or false, i would use python only tor things that i can’t do with logic bricks for now,
for example i tried to understand how to get constraint works on spawned object with python because not possible without, but i didn’t understand a single step of it…
are there helpful and detailed bge module tutorial!???

There is no tutorial. You have to read the API, run tests, do some experiments, and all in all figure things out for yourself. This is not just bge, this is software development in general.

i tried to understand the api documentation, sound too fragmentated, complicated and advanced for my knowledge with script

that’s why a guy made the famous (now dead) blender tutorialsforblender3d.com . I started to back-up all his work but with a more concise presentation (i made all the sensors) . You will quickly understand and be able to make your first python script

pick up a sensor you want (with it’s specific options in python)

here, all the common options available for all sensors

most basic example

# import bge module
import bge
# get the controller
cont = bge.logic.getCurrentController()
# get the sensor attached to the controller,  my sensor is named Trigger
sen = cont.sensors["Trigger"]

## now, the interesting thing    , careful !  python use tabulation indentation (so check) 
if sen.positive :
      print(' my sensor sent a positive pulse ')
else :
      print(' my sensor sent a negative pulse ')

you will quickly build your BGE python knowledges by seeing examples

i already know the basics but i don’t know how to use all settings of actuators and controllers/how to write them, for sensor i have to use logic bricks anyway to send the pulse, and anyway i don’t understand how can python help me with my game
at least i would need a script to put all things that have to be done if one action is playing but this game is complex, i will try to use script for next levels otherwise i will have to waist time to rebuild all if i have to replace logic bricks with script

you don’t need to rebuild everything. Just make a copy of your .blend. and make a python-version of your game. You will have nice time to fully comprehend what you are doing in your game and new ideas will come.

Yes, keep your sensors and even your actuators . The python controllers (you can make many) are very good to

  • filter and combine the pulse generated by the sensors, so you can make many “cases” in 1 python controller only (instead of having many AND , OR , XOR controllers)
  • dynamically set/change the parameters of your actuators ( for example, the action to play in an action actuator). So you can drastically reduce the number of actuators (1 actuator to play all your animations)

Also for the moment, as your game is “turn based” it works on kinda system “push button and play action” so it’s okey . But when you will want to start make your game more and more complex you will realize that the number of controllers and actuators are going to exponentially explode and you will have more and more hard times to find bugs in your logics. It will be impossible to maintain and at that point you will stop your project.

Well, it’s up to you ofc, but if you are planning to go further in your project, elementary python worth the little effort.

mmm one controller for all actions, it would be nice but there are things crossed between the objects in the scene, I have no idea then how to tell the object that controls the overall logic of the level, to perform the action of another object in the scene,
I could give it a try but I’m not sure I can
thanks!! if i will need (surely) i will ask to you :smiley:

You need to call a class or function for each object in the scene.
Do this by marking objects with game-properties or certain key-words & calling action(s) for each defined entity.

in python, you can change a property value of any object in your scene and use a property sensor on the object to detect it :slight_smile: Or you can simply use the messages and activate them in python.

Also, you can shift-select objects in your scene so you can link their logic bricks and make everything go through 1 single python controller.

But u don’t need to put everything in 1 python controller. For example, it makes sense, to put a initialization script in a separate python controller

all this sounds confusing for me, because there is not to think how to build the logic with python because the big part i need for it is knowledge that i don’t heve, i started to make experiment to control action actuator with python

classes and functions are too advanced for me

Python is case sensitive in this case it’s ‘blendIn’.

clases can be a pain at start, but functions are very easy, here is an example to play an action with python and changing some basic things:

# Connect this with python set to module mode, scriptname.test
# Make sure the script name in blender text editor ends with .py

def test(cont):
    #python connected to an object and it becomes the owner
    own = cont.owner

    # action name, start, end, layer, priority, blendin, mode(0=play,1=loop), layerWeight, ipoFlags, speed
    own.playAction('CubeAction', 1, 20, 0, 0 ,3, 1, 0, 0, 1.0)

    #to do something with an other object
    other_obj = own.scene.objects['other_object']
    #position change
    other_obj.worldPosition = [10,10,1]
    other_obj['health'] = 100

many thanks, it looks easy because i will only have to copy and change something, otherwise i will never understand how to do that, i’m gonna practice with this in a while