UPDATE: I find that sticking Invisible Occluder Blocks right behind the camera helps partially solve this issue. The game still seems to hate having to render characters partially if parts go “offscreen”. But there’s no frame drop.
Request: Is there a way to prevent characters from appearing into view until they are fully past the camera’s Global Z axis? Having NPCs and Enemies standing both behind and in front of where the camera is slows down the frame rate a lot.
Speaking of this issue, subdividing a big wall and splitting the polygons into separate meshes will prevent the game from dropping its framerate. But a one piece big solid wall will slow down the frame rate a lot if that wall starts going towards and past the camera.
you can either use the bge to hide the object or set transparency and specularity to 0
but i’m pre sure you can’t just use a ton of logic bricks, you need python.
import bge
cont = bge.logic.getCurrentController()
scene = bge.logic.getCurrentScene()
obj = cont.owner
x1=obj.worldPosition.x
y1=obj.worldPosition.y
z1=obj.worldPosition.z
scene = GameLogic.getCurrentScene()
camobj=scene.objects['Camera']
x2=camobj.worldPosition.x
y2=camobj.worldPosition.y
z2=camobj.worldPosition.z
distance = ((x2 - x1)**2 + (y2 - y1)**2 + (z2 - z1)**2)**0.5#please don't use "1/2" that's just silly. uses extra unnecessary processing power.
if distance < 1:
obj.hide()
or
obj.settransparency(0);
#honestly I forgot how to do these two things, but it is definitely possible as I have done them in the past. so you'll have to figure out that on your own.
else:
obj.settransparency(1);
or
obj.unhide();
sorry I can’t remember the commands for those two last bits, it’s just not in my memory. wish i could be more help, but yeah, it’s possible.
Either way it’s vector substraction, square each element and square root of the sum.
You could also numpy.linalg.norm(a-b) if you fancy, there really isn’t a difference between that, mathutils and a builtin that’s also written in c. Not that a human brain could notice either way.
But piece of advice, if you’re going to do vector math on every object on every frame, don’t do it in python. That’s what all these c libraries are for.
I am working on a few models with animations that I am willing to give away for free before releasing the actual game. So I can share blends before posting more questions.
Just wanted to say THANKS everyone for the suggestions though! I will post again when I can post blends with my issues.
Doing dumb things like looping through all your objects every frame is slow. Python is plenty fast enough for everything you’ll ever want to do with it. If Python is your bottleneck then you’re doing something poorly.
I could be wrong, but the way I circumvent this issue is by simply adjusting the clipping distance for the active camera in the properties tab. You can set both near and far clipping limits, so that objects that are super close to the camera will disappear (as well as far away)