CIV game in progress: lag due to logic editor

Hello everyone,

Note:
if you’re willing to help me i suggest taking a look at my game so far first before reading the rest of my message since it will most likely be much easyer to understand that way.
the game file should be included, i’ve also included a normal map and texture for the water tile if you want to see it, but its not necesary for what i want to know.

I’m making a fantasy CIV game with a friend and atm we just have a random map generator.
this uses a script where you can decide how big the map must be and how frequently certain tiles appear on the map.
the script uses 4 different 3D modelled hexagon tiles to place. those four models also have some logic bricks to make them go up if you click on them and go down if you click somewhere else.
the problem is however, that when i create quite a big map, say, 10 by 20 tiles, the logic will start to use a lot of cpu power if my mouse is over a forest tile. for some reason this even happens when i just delete all of the tiles logic bricks.
and it also cant be the amount of vertices since it doenst have that much more than the mountains tile.
I really dont understand what causes this and i would really appreciate some help! thanks

Attachments



GameMap.blend (1.74 MB)

Hi Tom.
You can do a few things here to improve performance. Firstly you should set the Collision Bounds shape of every tile to something cheaper to detect, like a sphere or a convex hull. That should make it easier for your CPU to process the collision.
The second thing you should change but you don’t have to, is to detect what tile the cursor is on, using only one object and MouseOverAny sensor, but if you don’t know Python that well you can leave it like it is.
Good luck with your project.

As Josip said, don’t use multiple mouse over sensors. They each perform individual mouse queries. This should really be cached between sensors, but it isn’t at present (idea for any interested parties).
Here’s a painless Python conversion. It sets a mouse_over property on selected objects, and I’ve included a simple conversion script if you have any scenes already set-up. You’ll need to copy the MouseManager.py and the mouse_manager empty into the file though.

You can also get rid of the mouse script; You can ask Blender to show the mouse cursor in the render options (ensure you’re in Blender Game engine mode)

Attachments

GameMap (1).blend (1.74 MB)