FPS template based on Social's template

I’ve been working on Blender for the last couple of weeks and I thought I’d share my experience. I got sucked into it when I saw my son doing impressive things on Blender. He’s a fan of Metroid Prime, that’s why I looked at FPS (you will recognize the style of doors).
I started from the Social’s template and added a bit to it. The sound is from www.soundsnap.com and the bot model from www.turbosquid.com. The result as it stands today can be found here: FPS_template_14.blend
My focus during this development was performance. So I ended up using less logic bricks and more scripting. For example, the door system is entirely managed by scripting, no ray/near/collision sensor, just simple distance calculation done centrally.
The result is that logic processing stays at 5%, even after adding four doors and two bots with basic intelligence.
I would encourage everyone making games on blender to use more scripting. Python is really easy and powerfull.
Of course I had a lot of problems and frustrations but I’ll described them in a separate post.

Updated template with dynamic room creation: FPS_template_15.zip

Can we see screens of the new capabilities and the full list of added features, use the attachment option to upload images from your computer.

For doors I just used distance and an IPO that opens then closes it, I set the sensor pulse rate so it doesn’t fire again immediately.

say ben2610, you wouldn’t happen to be a game developer would you? Because the whole playing around for two weeks and already editing the fps template by adding metriod style doors and simple bots thing kinda screams professional.

some problems, maybe my fault?!
The doors open but the player can pass trough ( probably parenting not working?)
And the bots disappear when I start the demo?

Welcome to the forums, nice to see some serious developers around here.

The door is stopping the player for some reason,
The bots where there the first time I ran it, but the second and third time no bots at all.
The BGE can make some nice stuff but is not really set up for a FPS.
If you took your python knowledge over to the crystalspace engine, I bet you could make a kick ass game :slight_smile:

  		God made me an atheist, Who are you to question his wisdom?

you really krack me up man!!

As far as this demo goes, I have some trouble with the door too, but I get bots.
The only other problem I see is that you realy are not getting very good frame rate at all on my older computer.

My family is the exact opposite, my children are seeing me make the cool stuff and I am able to teach them. It really has brought me and my oldest boy closer.

Thanks for these kind feedbacks. I’m not a game programmer but I’m indeed a professionnal programmer, mainly active in Telecom. I spent more time and enjoyed Blender more that I would expect. But I can also see the limits so I might have a look on crystalspace.
Quick answers to questions:

Game play: I’ve updated the introduction text with full details on the game play and the rules to follow if you want to extend the game. The latest template can be found in the first post of this thread

Door method: I used armature rather then Ipo because it would otherwise require 6 objects for the 6 door segments. I realize that I should probably have used that method but I sticked to my initial idea and managed to get it working with a shield.

How to open doors: you must fire the shield to remove it

bot behaviour: read the Text document in the blend file

frame rate: I can’t get 60 fps on my Athlon 1800 computer (with RADION 9200 gfx) when I run full screen but it works ok on a quater size screen. I managed to maintain the fps through out the development.

I don’t know if I will have much time to develop further this template but I will certainly continue.

Excellent work, ben!

I’m surprised that the framerates weren’t affected too badly–especially with two rigged characters walking around.

I’ll have to study this method of opening doors. Seems to be the best way to do it. (I wonder how it will work out with multiple scenes.)

Anyway, thanks for sharing. This will surely help the game engine community here.

The bots are un-able to walk around objects in thier path, i tried putting some boxes in room2 and the bots just keep walking at them. you are also un-able to jump ontop of the boxes. IDK, just some ideas.

Some details of door system: I first used a near sensor and it worked well but consumed massive CPU and created some instability. So I changed into 2 ray sensors on both sides of the door. I then added a collision sensor on the armature because the ray would leave a “dead” zone around the center of the door. Then the door system was consistent but consumed CPU and in addition, prevented to shoot across the door because the armature collision zone would intercept any ray sensor. Finally, I removed all sensors and replaced by a script computing the distance between player and doors (look at walk.py).
At startup, the doors will register a rectangular collision zone and a pointer to themselves. The registration is indexed by room name so that the player can just check for the relevant doors.
Altogther it is very cheap in CPU and perfectly stable and consistent: the door is really opened. With the ray and collision sensors you could “hide” staying in the middle of the door.
Whenever a door opens and closes, it will do simple vector calculation to find out on which side of the door the player is located and tell everyone that the player is entering or leaving a room. This could be used to delete/create rooms on the fly to keep the world small.
My next efforts will be on dynamic world extension, changing scenes, more bot intelligence such as random running to escape from the player’s fire or look after him if he’s hiding.
I also want to create some kind of bot API which automatically takes care of stopping things when a bot state is changing so that the user can concentrate on starting things only. I did it already for armature animation: BotAction() kindly remembers which actions were running and stops them before starting the new ones.

Dude…2 weeks…neat :wink: So what kind of programming do you do? Networking? I suppose?

Yes networking, VoIP, protocol stacks, API, multi-threading, real-time engine, clustering, etc. All related to telecom.

Here’s my idea for dynamic creation of rooms:
Each room will be owned by a door. The requirement is that the room has exactly the same center and orientation than the door. The door will know which room it can create through a master property. When the player arrives at the door, the door will check if the room on the other side exists already and if not, will created it. The conjuction of center and orientation makes that the room will be correctly positionned. If the player comes at a door that is not the room owner, the door will send a message that the room owner will catch.
In turn, each room will know all the objects that it must spawn when it comes to existence. This information will be packed in a string property or text document or disk file. It will contain the name of the objects, location and orientation. The room creates those objects using an empty spawner. While this is happening, the door remains closed. When the room is ready it sets its ready property and the door finally opens.
When the player leaves the room, the door will check if the room must be deleted. All dynamic rooms will have an “end” property. The door sets it to signal the room that it must die. In turn the room will kill the contained object in the same way.

I’ve already tested the basic principle and it works fine. Some questions remain opened: can objects be created at once or one per frame, how to avoid movements in the room while the room is being setup.

Setting up rooms like this will be difficult so I intend to create a script to be used in the 3D view to setup all things automatically. The idea is that you create rooms statically, test them well and when you are satisfied, run the script that will create all properties and set all values right before pushing the rooms and objects to another layer so that they don’t take space in the active layer. You can of course decide to put the room back in the active layer for more static testing and run the script again later to make the room dynamic again.

If it works well, it should be possible to build really large maps without impacting on performance.

You could use a game engine with a real portal/antiportal system like Crystalspace and focus on your artwork, and your gameplay :slight_smile:

And the problem with “large maps” is, probably, that you’ll not have the time/patience to make it?! :slight_smile:

I looked at crystalspace very quickly and it seems indeed much more oriented to game but the learning curve seems large and I don’t really want to be in game development.
My interest in 3D games is probably limited in time so I’d prefer to continue with Blender and do something useful for the community here. I certainly don’t have the time to build large maps but if I can make life easier to people willing to do so, I’d be happy.

Wow, those are some good ideas. i dont have any suggestions, lol. very nice work ben.

It took some time but here it is: this version of the template will have dynamic room creation. As you walk through the rooms, they are created and destroyed dynamically. Note that the *.dat files are needed to create the rooms, make sure you unpack them in the same directory of the .blend file. Creating those files is made easy with two embedded scripts: saveroom.py and loadroom.py.
All the rooms look the same so it is a bit boring but it’s not at all a requirement.
You will find explanations in the Text document.
Hope it’s usefull.

You will find the link to the latest template in the first message of this thread

It was my understanding that even though you have objects on a different layer, they are still in memory and not released. They just are invisible, so to speak.

but if they are in a file, that could be a different story. smile.


It took some time but here it is: this version of the template will have dynamic room creation. As you walk through the rooms, they are created and destroyed dynamically. Note that the *.dat files are needed to create the rooms, make sure you unpack them in the same directory of the .blend file. Creating those files is made easy with two embedded scripts: saveroom.py and loadroom.py.
All the rooms look the same so it is a bit boring but it’s not at all a requirement.
You will find explanations in the Text document.
Hope it’s usefull.](http://www.filecrunch.com/file/~uduwpy)FPS_template_15.zip

good job , the 15 ver shows 404 error , fix the links

the soldiers didn’t appear in the game
thanks for sharing
Good Luck .