So as already known the bricks in python for the game engine, can’t create the best effect as raw python code can.
So this basic example, I have setup, a cube moves to the target, but can only go at the speed setup by a brick, as with the code, you can add variables, so it moves at a certain time, and speed in order to create a realistic AI - player interaction.
In one of my small mini game projects this is exactly what is going on, how ever when I think about it, is it the AI that is too big or small, that gets wiped out by the player’s bullet, or is the scene too small for that type of interaction and the speed of some using the steering brick. Since there is also no control of the bullet firing object. That requires animation and a cursor point/cross hairs.
Is the brick setup pretty much at its limit as my basic example shows. I used 2.76 here
Hi - use that steering.velocity = 0.100 or use float property - own['speed] and insert in steering, steering.velocity = own[‘speed’], if you use property you always control and assign speed for movement unit. I hope you understand how connect actuator steering in python controller brick for use python scripts - because set speed for steering only logic brick impossibly
Yes, you need a script for managing the unit Logical blocks and Actuators will be sensors and execution blocks they can be obtained in the script. The problem with using the steering drive is different - it cannot bypass three objects standing in a pile or in a row that have the property of obstacles because it falls into the local minimum to solve the local minimum problem, you need to use a beam obstacle avoidance system if the unit is stuck and cannot find the right solution. If you need a script that will start the steering drive actuator here it is -
def start(cont):
from bge import logic
scene = bge.logic.getCurrentScene()
own = cont.owner
speed = own[‘speed’]
steering = cont.actuators[‘Steering’]
if not ‘start’ in own:
steering.target = scene.objects[‘Target’] # assign target you can assign goals that are located on the layer in which the unit is located
steering.distance = 1.000 # assign distance off steering you can set the distance to turn off the actuator depends on the distance to the target
steering.velocity = own[‘speed’] # assign speed
steering.navmesh = scene.objects[‘Navmesh’] # assign navigation mesh you can assign a navigation mesh-even if it is loaded via bge. logic. LibLoad()
cont.activate(steering) # start use steering
cont.deactivate(steering)# stop use steering
You can use this text as a starting script i use something similar and all work, you will need to indent (tab) in text - after the colons there are two spaces, note that if the condition is shifted and a colon follows it, then four spaces are already considered from the edge, create a sensor that will set the start of the script execution - keyboard key or delay for start, and you need a controller block with a script and a Steering actuator, need create property float “speed”, in scene need objects - navmesh with the name Navmesh and target with the name Target
SimplePathfinding_Steering.blend (552.0 KB)
Hi i create simple example for pathfinding and use actuator steering - use UPBGE version 0.2.5, i make navmesh, unit and target, if you click right mouse button in ground you start unit and assign target - script is very simple, i hope this example help for you
The problem is my file is from blender game engine, not the use of upbge, the recent file I was trying to get up and running that needed code, spider smith battle works in upbge.
So my example I have made in the game engine, would need to work for a file that works in that engine, not upbge. If this was for the recent file I may of considered trying to do that upbge. I’m not a programmer, at the end of the day. So the file I am focusing on won’t work for upbge.
I tried that, nothing appears to work. I am using 2.76 blender 3d. So if you made this file in upbge,it could be the reason. Some files may not work when done in upbge and then load into blender 3d. The spider smith file works in blender game engine and upbge. The only one.
I would need any python program for blender game engine since the file was made in it.
The file does work, in upbge only. My wip file is in this clip, so you get the task I’m trying to get working. The AI is following the player, so in order for there to be a bit of an equal challenge, python code is the only real alternative than the bricks, isn’t bad, but for example, an ai at the very back can’t accelerate once the AI has been wiped out.
Just translate logic bricks, script, and objects in BGE frome UPBGE blend file, not use copy insert and not use append objects, create new file in bge and reconstruction my example and append text script for drive unit
Hmm, the file example doesn’t quite make out what the file I have in the video is doing. So the purpose of a python code script is to be able to control the speed, so once some AI are taken out or removed from the scene, the next AI need to be able to accelerate ahead to attack the player.
As my example file at the top of the topic shows the file example as shown in the video.
If the front AI is 1,000, then the back AI need to be 2,500 or something. As is, it doesn’t quite work for it to be a challenge. At least not a difficult one.
If you use python and steering actuator in units for pathfinding or finding and tracking to player you always assign or change speed in actuator steering - you need get actuator steering = cont.actuators[‘Steering’] and assign new speed - steering.speed = 5.000, I’m only telling you how to contact the actuator, but the conditions under which the speed change occurs and something else you should write yourself to check the line of sight use ray = own.RayCast (end, start, 0,") where the end and start variables are from where and where the beam is thrown hit = ray[0] will get an object and you can check its properties to change something in the steering actuator
I was thinking about the program, and using the bricks to may be pull this off. I think I can, by using a property, once one AI has been edited or removed, the property would switch on to then make another AI further back accelerate with a new steering brick. It could work…
Then you will need several steering drive actuators with different speeds - but the problem is that they will be configured for only one purpose and will have one navesh, yes, they can be switched back and forth and it will work but such a system will not be very flexible
Dont use collision sensors, replace sensor collision to ray or radar sensors - this sensors registrations detect collision best or use ray cast method
start = own.worldPosition
end = enemy.worldPosition
ray = own.rayCast(end, start, 5, ‘property’)
hit = ray[0]
if hit:
if ‘enemy’ in hit:
enemy.endObject()
in this method objects cast ray to target, just assign start object, end object or position xyz how variables, check physics you objects if objects not actors impossible collision detection
I tried a ray and a radar brick for ai1, and set it to actor as static for physics, there is no change. They just collide with each other, and ai1 should be removed.