Top-down Race Game Template *New Screenshots*

I’m working on a game template to let people make top-down race games easier. Right now I got a simple driving system, track, and a few props.


Alpha 0.2:
Alpha 0.3:
Alpha 0.4
Alpha 0.4.2

May 11/12 - Made track, car (inkscape), and added/modeled props.
May 12 - Added better lighting
May 17 - Set up library linking and updated the track a bit.

DONE Better gas/break
Times (see if you beat yourself)
Menu (with car and roof decal select)
2-3 Tracks

In other words, release a open source game, and make it super easy for people to make their own games by importing several objects.

Sounds like a good idea, how about making a simple website where people can post links to different tracks they have made for the game. Similar to freerider?

Good idea, if I finish this I’ll work on a website to :slight_smile:


Updated driving performance. Drives just like I wanted it (drives like the game Pro Rally 2, check other videos on my channel)

That’s really nice! I’ve always liked this kind of games. I remember that I tried to do a similar game to this when I was learning Blender (still does:D).

Anyway, I read on your “Tracks … ?” thread from “Game Engine Support and Discussion” that you doesn’t want to learn python, but still wanted to add AI to this game. I don’t know if you already knows a way to do this, sure you can use ipo’s but the car that you are driving would just stop if you crasches into it. Therefore I decided to share two codes and a tutorial how to add it (the code isn’t written by me from scratch, but unfortunaly, I can’t remember who did this first). Anyway, it’s quite easy to setup.

To start with, add some empties and place them around the track. You can name them anything you want to, but if you doesn’t name them the same way as I, you will have to change the names in the codes too. I’ve named them:
and so on as many as you need. Those are the objects that the AI will follow. But you’ll also need one named:
Here, the vehicle will restart after a lap. But you will also need one named:
this one will only controll the car.

Now what you need to do is to select your “gameData_ob” and do following:
Add one “Always” sensor and one “Python” controller. Add one new code and paste in this code there

GameLogic.pathForw1 = ['pathNode_ob', 'pathNode_ob.001', 'pathNode_ob.002', 'pathNode_ob.003']

Note: If you used more empties, which I guess that you have too, you will have to add their names just as I did.

Note2: It will go to the next empty in the list, so write them in the same order as they are in the track.

Now select the AI car, add a new text and paste in this

import Mathutils
# get the controller the script it attached to
controller = GameLogic.getCurrentController()
own = controller.owner #get owner
# get a list of actuators connected to the python controller
actList = controller.actuators
nextNode = own["nextnode"]
#get nodepath to follow
pathchoice = own["pathtofollow"]
glVar = ("GameLogic." + pathchoice)
path = eval(glVar)
#collect nodelist from global variable
track = actList["targetnode"]
travel = actList["movetonode"]
#Check distance from targetnode. switch to next if close enough
targEmpty = path[nextNode]
pathlength = len(path)
distance = own.getDistanceTo(targEmpty)
if distance < 9.0:
 nextNode += 1
 if nextNode == pathlength: #At end of path, respawn at spawnpoint
  nextNode = 0
  scene = GameLogic.getCurrentScene() #Get the scene
  respawn = own["respawnpoint"]
  spawnpoint = scene.objects[respawn] #Get spawnpoint_ob and get xyz
  spXYZ = spawnpoint.position
  own.setPosition([spXYZ[0], spXYZ[1], spXYZ[2]])
track.object = path[nextNode]
#set proprty to new value
own["nextnode"] = nextNode
speed = own["travelspeed"]
spdXYZ = [ 0.0, speed, 0.0]
travel.dLoc = spdXYZ

Now, setup the properties and logicbrick just as I did.
Note: The name off the properties and logicbricks has to be exactly the same as in the attached picture.

Now it should work, only hopes that this will work for you, and that you still are using 2.49, otherwise these codes wont work. Also hopes that this will come in use for you.

Last note: If you want the car to drift just as the car you are driving, just change the property “travelspeed” to 0.000 and hook up this Always -> And -> Motion, and in the motion, change so that it’s the same as the trottle in your car.

Also, in the “Track to” actuator, it stands “pathNode_ob.001”


Updated with new video

Thanks dude :open_mouth: I’m going to try this!!

edit: something is causing the game to crash when ever I press P …

Updated with new screenshots (the lap 1/3 is just a dummy right now, doesn’t work)

Nice video. Only one disepointment. You are using Blender 2.5. That means that the codes won’t work:(. If you not want to switch to 2.49, I can try to convert these codes to Blender 2.5. Not sure if I can make it througt, but I can try. I’am not very used to this new version, but after finishing my game, there will be a stable release, and then I’ll start learn it. Just hope for the best.

Template looks like a lot of fun! I might just have to try this out…

Nope, I’m using 2.49

BTW I didn’t add all the scripts yet, wasn’t even finished setting it up before it crashed (had to re-size my car and I was going to play it to make sure it still worked right). Do I need everything in your tut set up to make it work?

Ooops, then you were using an other theme than I do, sorry. Well, yes you need to setup EVERYTHING as I said, becouse the two codes are working with eachother. They are also searching for the exact name that I showed and wrote down for you. If it finds to many errors, it might crash. But if there just is a few errors, you can see what is wrong in the console.

I made a test file and copied everything, I even copied names right from this thread. :frowning:

And what happend then?

The AI car didn’t move, lol, for some reason. I can send it to you if you want

OK, please send the file to me, and I can see what’s wrong. Maybe I’ll forgot to say something:o. Anyway I think that I can fix the problem pretty fast if I have the file.

Could you send the file to me so that I can fix it?

Missed your post! sorry! lol