UPBGE Logic nodes performance issues

Hi everyone, I didn’t post enything yet in blender artist but a couple of months ago i decided to try realyze a game with UPBGE (because i’m a blender user and i thought “wow, would be great if i could do everything from start to finish inside a single software”) and decided to use only logic nodes (I sincerely hate logic bricks, they are really too chaotic for me) and i find nodes a great way for keep things organized and clear, also because i can keep different type of code separated.
BUT in the last few days i found a huge problem of performance.

in the video i add the enemy by pressing a button, and after a few enemies added the frame rate goes down.
I’m using low poly models and low res texture (max 800 tris and 256x256 texture each model:i’m trying to recreate psx style) and obviously not using lights and shadows. I will use a low frame rate, maximum 30 fps, mut i’m testing at 60 fps because if i have no problem i will also have no problem at 30 fps (I suppose).
i thought that with that low res models and texture everything would be fine, but i was wrong; i also noticed that the biggest problem is the logic, so my questions are:

1:why is logic so heavy? the enemy has 7 node trees applied, , the player 8, one for the attack, one for running , one for the gravity (he has the character physic type with maximum fall speed but wasn’t enough)ecc…and a state machine node tree wich decide wich tree should stop or start (the enemy, and also the player, have a string type property called “state” that decide that). Is this the problem? too many trees?

2:the player has a node tree for targeting the enemy, when the enemy is targeted his life bar and the “target cursor” shoul appear with the “set visible” node, but i must delete this funcion becouse if i use it the frame rate goes down of of something like 15 fps, and the rasterizer achieve more than 40%, why?

3: what are depsgraph, outside and how precizely rasterizer works? how to deal with all those thingg and optimize the game?

i have an Asus rog strix
16gb ram
6gb vram
‎Core i7 8750H
gtx 1060

i know is not a great computer, but i thought it should be enough to do those such of things.
thank you and sorry for my english :smiling_face_with_tear:

You might want to test my script for converting logic nodes to python scripts- Here

Also, the currently translated node functions, and system to translate functions- Here

Note that I haven’t translated most node functions for it, but besides that, the script is theoretically operational. It can take a while for large trees, so it’s not really meant to replace the current system, but to use the current system for rapid prototyping, then finalizing it into something faster.

Setting that aside, from what I can tell, the problem with logic nodes is that many run with no conditions. Large numbers of logic nodes can grind a scene to a halt, even when they aren’t doing anything. My solution is to convert the trees into python scripts, with condition trees for each node, then either use logic bricks to run the scripts, or use a really simple logic tree that goes say [On Update-> Run Python Script]. I’ve successfully sped up several large node trees based on this premise. Conversely, I’m sort of a fan of logic nodes, but hold that the compiler really needs to be better.

1 Like

Try “logic culling” does this work with logic nodes??

It’s in the object property tab

I don’t know how it works precisely, probably i tried it but nothing changed

I’m not a programmer, and i don’t really know how to apply this method to my project: where do I have to attach the script? Is this method enough to allow me code the entire game only with nodes without any performance issue?anyway it wuld be great if you could show me how to use the code

The script should be copied into blender’s text editor to be run from there. In theory, the only thing you need to modify in the script itself, is to replace the name of the node tree located at the bottom of the script with whatever your node tree is named, and to set the text output name to whatever.

In practice, the script’s a work in progress. I fully expect it to fail in some weird way that I didn’t expect, and even if it works, I’ve only defined the nodes that I actually use, so it’ll probably report some of the nodes as unrecognized. I can’t recommend this as a replacement for understanding at least a basic level of python.

What you described is the use case that I’m trying to address here, but I would answer that the problem isn’t your node trees, it’s that logic nodes themselves aren’t up to the task, and it’s currently fundamentally not possible to get a (more than slightly complicated) upbge game working without writing it mostly in python.

Thank you for the answers, i really appreciate your efforts, but I don’ really understand why nodes are so heavy (probably because i’m not a programmare) ; is someone doing something to make logic nodes usable like logic bricks? Anyway, i think a will switch to armory util logic nodes becomes more accurate and faster :’)

Learning py, and having 1 single script doing a bunch of work is recommended, if you are hitting a wall.

What are you trying to do that you can’t?

python itself is a very slow language, and thats compounded by the generic coding of nodes.

there is no substitute for efficient, well planned and organised code.

I’ m trying to make a game with logic nodes only because i love nodes, that’s all. I thought i could, but I was wrong

I know, but I dream a world made by nodes :’)…perversions…

Make a piece per frame, if you need to, and delete a piece per frame, (that is how my world chunkier works)

Dose logic culling work based off of prximity to the current active camera? Like if i switch camera in game, at a farther location, will effect the logic cull?