hello, some time ago I had a drop in FPS due to my ammunition presence.
dropping from 60 to 30 FPS when there are many and resumes at 60 when the ammunition is disappearing.
my ammunition is a type, which has an object which I move.
If the munitions are active, they calculate possible collisions with other planes or ships.
They only activate, when they are close to another object.
For example, if I fly with my plane alone, and shoot, the ammunition does not calculate collisions since they would not have to hit. And so I save the whole process of detecting whether or not they collide with something.
My ocean is always at height 0, so if its height is negative, I know they fell into the water.
I would like to consult you, what is the best method to have a lot of ammunition and that AppGameKit can handle it without falling.
and what method is better to calculate if a munition had an impact.
share some part of my code, this is when i create a ammo when someone fire.
----------------------------------------------
My idea, for now, is to replace the projectiles with a more effective method, I have everything separated into functions.
- projectile creation
- update projectile
- I calculate if it collides or not
- projectile death
damage calculations and others are in different functions.
it's obvious that I'm doing something wrong, and I lost track of when I started getting this drop in FPS.
Are there ammunition systems for shaders? Or is there a more polished system for this type of need?
----------------------------------------------
thanks for read,

, im back to dev again.
regards!
+ Code Snippetfunction crear_disparo(origen,tipo$,flag,origen_id)
m as municion
m.tipo$ = tipo$
// estas dos deberia racionalizarlas en una sola, esforzate!
for count = _molde_municion.length to 0 step-1
if _molde_municion[count].tipo$ = tipo$
if _molde_municion[count].obj <> 0
existe = 1
//print (" VOY A COPIAR LA SIGUIENTE MUNICIONNNNNNNNNNNNNNNNNNNNNNNNNNNN " + tipo$)
m.obj = InstanceObject(_molde_municion[count].obj)
endif
endif
next Count
if existe = 0 //si no existe esa mucnicion, la crea y de paso copia la nueva municion al nuevo disparo
//print (" NO EXISTE NO EXISTE NO EXISTE NO EXISTE NO EXISTE NO EXISTE NO EXISTE ")
crear_molde_municion(m.tipo$)
for count = _molde_municion.length to 0 step-1
if _molde_municion[count].tipo$ = tipo$
if _molde_municion[count].obj <> 0
existe = 1
//print (" VOY A COPIAR LA SIGUIENTE MUNICIONNNNNNNNNNNNNNNNNNNNNNNNNNNN " + tipo$)
m.obj = InstanceObject(_molde_municion[count].obj)
endif
endif
next Count
endif
m.origen = origen_id
m.flag = flag
pos(m.obj,origen,"crear_disparo")
rot(m.obj,origen,"crear_disparo")
m.activa = 0
m.vel# = 10.4 * 2
if m.tipo$ = "proyectil aa" then m.vel# = 10
force_add_vector(m.obj,m.obj,m.vel#,0)
color = random(0,255)
setobjectcolor(m.obj,color,color,color,255)
_muni.insert(m)
endfunction m.obj
+ Code Snippetfunction update_muni_proyectil(count,force_n_id, debe_morir)
//force_n_id = force_getmyforce_n_ID(_muni[count].obj)
if _muni[count].tipo$ = "proyectil" or _muni[count].tipo$ = "proyectil aa"
//set_timer("proyectil A",0,3)
if _muni[count].activa = 0
if getdistance(cam_pivot,_muni[count].obj) < 100
_muni[count].activa = 1
endif
endif
//set_timer("proyectil A",1,3)
//set_timer("proyectil B",0,3)
x1# = getobjectx(_muni[count].obj)
y1# = getobjecty(_muni[count].obj)
z1# = getobjectz(_muni[count].obj)
force_apply(_muni[count].obj ,force_n_id)
//MoveObjectLocalZ(_muni[count].obj, 1)
//set_timer("proyectil B",1,3)
if _muni[count].vida > 1 and _muni[count].activa = 1
// posicion nueva de la municion ?choco algo?
//set_timer("proyectil C",0,3)
x2# = getobjectx(_muni[count].obj)
y2# = getobjecty(_muni[count].obj)
z2# = getobjectz(_muni[count].obj)
//set_timer("proyectil C",1,3)
//set_timer("proyectil D",0,3) //start timer
//Calcular si va a chocar contra algo
ObjectRayCast(0,x1#,y1#,z1#,x2#,y2#,z2#)
n=GetObjectRayCastNumHits()
// set_timer("proyectil D",1,3) // end timer
// set_timer("proyectil E",0,3)
for i = 0 to n-1
victima = getObjectRayCastHitID(i)
if victima <> 0