The first time an object enters camera point of view...

It might be a bug, or my PC, i don’t know.

When GE starts and an object is going to enter the camera point of view for the first time, GE hangs for nearly a second, even if the object is just a cube.

I tried to solve this by setting a initial camera viewing all objects in a scene, but it keeps doing it, when camera changes.

Hope you understand me.

Thanks a lot

Ive come across something similar but not with just a simple cube, guess it will depend on how fast your computer is. It seems the engines frustum culling that culls objects out of view will cause bge to not pre-load objects. so at first frame start up I got around this by disabling frustum culling and then on the next frame re-enabling frustum culling.

This then stopped the camera stuttering for me when first viewing a lot of objects. I guess other game engines pre-load objects around the player within a short area, but we don’t have any sort of function like that built in.

Only weird thing about your case is you said objects continue to cause stutter when they enter the camera view frustum again which is odd as this doesn’t happen for me.

also a heads up simple shadows cause stutter on first game load also at the moment, oddly enough variance shadows are fine though, trying to get round to reporting that to tracker. you can do the frustum trick with the code I posted below, see if it works for you. fyi you have to disable occlusion culling in the menu settings for the script to work as that use’s some other method for doing frustum culling I think.

from bge import logic
scene = logic.getCurrentScene()

camera = scene.objects['yourcameraname']

def true():
    
    camera.frustum_culling = True

def false():
    
    camera.frustum_culling = False

Thanks, it is a shadow problem, a camera views the full scene from below and all objects are loaded.
But then i set to another camera and drive a tiny car, when an object is iluminated and casts shadow (simple or variance) for the first time (a shadow casting sun follows the car), i get another pause… how can i solve the shadow problem?.

EDIT: I think this could solve it. First set “SunLamp.shadow_frustrum_size” to a very big value so that all scene has very low quality shadows, then set “SunLamp.shadow_frustrum_size” to 70 and play.

How do i write the code to do that?

Thanks a lot!

There’s no python shadow map frustum size function im afraid. The shadow stutter problem I mentioned from all my testing is only on first start up and also happened to me with simple shadows, So when you first press p in blender or initial blenderplayer startup.

Also sunlamp shadows are not built for shadowing large areas yet, you shouldn’t go over 1024 res with them. Guessing you didn’t try the method I mentioned with the camera frustum?

I tried your method, the game stops before casting a “new” shadow.

Yeah I have too noticed that effect of slowing down when looking around for first time. Will try that script for sure.