Hi
In some of my game level, the fps drop at 30 (instead of 60). I know my PC is really slow ^^, but I would like to know if you know technic to optimisate a game or a level.
I have tried :
For i=0 to Tree.length
n = tree[i]
if GetDistance3D(GetObjectX(player),getobjectY(player),getobjectZ(player),GetObjectX(n),GetObjectY(n),GetObjectZ(n))<1000
SetObjectVisible(n,1)
else
SetObjectVisible(n,0)
endif
next
But :
1) it's not very accurate
2) the fps drop when the loop is on this part (to test the distance between the player/camera and the objects).
So you have some ideas to get a better fps ?
- For example, how can I do a LOD system ?
- perhap's I could turn off the physic for objects far of the player ?
my scene is "only" :
- 40000 polygons and 220 objects (with box physic (250 static box, 1 ground (terrain with 6000 poly) and 1 character (1000 poly)).
Here is main loop (test) :
do
if getpointerpressed() or GetRawJoystickButtonPressed(1,1)
jumped=1
Jump3DPhysicsCharacterController(player)
endif
joystick_y# = GetRawJoystickY(1)
joystick_x# = GetRawJoystickX(1)
Move3DPhysicsCharacterController(Player,0,0)
if joystick_y#>0
Move3DPhysicsCharacterController(Player,1,u)
endif
if joystick_y#<0
Move3DPhysicsCharacterController(Player,2,u)
endif
if joystick_x#<-r#
finalRotation = finalRotation - rotationInc
Rotate3DPhysicsCharacterController( Player, finalRotation )
endif
if joystick_x#>r#
finalRotation = finalRotation + rotationInc
Rotate3DPhysicsCharacterController( Player, finalRotation )
endif
Step3DPhysicsWorld()
setcameraposition(1,getobjectworldx(ObjCam),getobjectworldy(ObjCam),getobjectworldz(ObjCam))
setcameralookat(1,getobjectx(player),getobjecty(player),getobjectz(player),0)
setpointlightposition(1,getobjectx(player),getobjecty(player)+2,getobjectz(player))
For i=0 to Tree.length // 200 trees in the levels
n = tree[i]
if GetDistance3D(GetObjectX(player),getobjectY(player),getobjectZ(player),GetObjectX(n),GetObjectY(n),GetObjectZ(n))<1000
SetObjectVisible(n,1)
else
SetObjectVisible(n,0)
endif
next
For i=0 to House.length // 50 houses in the level
n = House[i]
if GetDistance3D(GetObjectX(player),getobjectY(player),getobjectZ(player),GetObjectX(n),GetObjectY(n),GetObjectZ(n))<1000
SetObjectVisible(n,1)
else
SetObjectVisible(n,0)
endif
next
Print(Str(ScreenFPS())+"|"+str(GetVerticesProcessed())+" | Phys : "+str(Get3DPhysicsTotalObjects())+" | Poly : "+str(GetPolygonsDrawn()))
Print(str(joystick_y#)+"/"+str(joystick_x#))
Sync()
loop
AGK2 tier1 - http://www.dracaena-studio.com