My next task is to make a braking system (easy enough in part since its the same system as what I have now, just on the y (forward) axis)- the big question is how I trigger it. I did have a brainwave for making waypoint nodes hold 'speed limit' data, but it may be a case of experimentation
As far as Blender goes (I assume Unity too), rays / radar functions are CPU costly- have you thought about using a system similar to mine which uses references to the objects linear velocity? My AI uses no rays (yet
) and it seems CPU friendly so far (but then......I have no eye candy yet!). Here is my blender script:
Code:
import GameLogic
cont = GameLogic.getCurrentController()
own = cont.owner
Xspeed, Yspeed, Zspeed = own.getLinearVelocity(True)
Anti_L_slip = [ -200.0, 0.0, 0.0]
Anti_R_slip = [ 200.0, 0.0, 0.0]
Anti_UP_slip = [ 0.0, 0.0, -120.0]
Anti_DOWN_slip = [ 0.0, 0.0, 120.0]
local = True
if Xspeed > 1:
own.applyForce(Anti_L_slip, local)
if Xspeed < -1:
own.applyForce(Anti_R_slip, local)
if Zspeed > 1:
own.applyForce(Anti_UP_slip, local)
if Zspeed < -1:
own.applyForce(Anti_DOWN_slip, local)
Its really basic but it works, and it may be of some help to you. The only other option would be to lower the time the script is run per second (in Blender this is called frequency). The only problem with this is that some things need to be done constantly (like steering!) whilst others (like race positions) can be done ten times a second/game tick rather than 60.
And I too hope my game gets finished! As a hobby Blender (and making games) is fun but its nice to see something work at the end of it all!