Thank you for your reply, I understand what you did but it doesn't seem to work for me for some reason.
Please check this example of my project that I made, you don't need any assets:
// set window properties
SetWindowTitle( "3DCollision" )
SetWindowSize( 1024, 768, 0 )
// set display properties
//Set display properties
SetVirtualResolution(1024, 768)
SetOrientationAllowed(1, 1, 0, 0)
SetCameraPosition(1, 0, 0, -11)
SetCameraLookAt(1, 0, 0, 0, 0)
SetGlobal3DDepth(2)
//Create Main Light
CreateLightDirectional(1,-1,-1,0,255,255,255)
//Create Objects
Player = CreateObjectSphere(30, 30, 30)
SetObjectScale(Player, 0.05, 0.05, 0.05)
SetObjectPosition(Player, -1, 0, 0)
SetObjectColor(Player, 255, 0,0,255)
Shield = CreateObjectSphere(30, 30, 30)
SetObjectScale(Shield, 0.02, 0.1, 0.02)
SetObjectPosition(Shield, 0.5, 0, 0)
SetObjectColor(Shield, 0, 0, 255,255)
Dim Bullets[-1] as integer
TemplateBulllet = CreateObjectBox(0.5, 0.5, 0.5)
SetObjectPosition(TemplateBulllet, -20, 0, 0)
SetObjectColor(Shield, 0, 255, 0,255)
do
//Spawn Bullets
If Timer() - Time# > 1
Bullets.length = Bullets.length + 1
tempBullets = CloneObject(TemplateBulllet)
SpawnLocation = random(1,2)
Select SpawnLocation
Case 1
SetObjectPosition(tempBullets, 4, 0, 0)
EndCase
Case 2
SetObjectPosition(tempBullets, -4, 0, 0)
EndCase
EndSelect
Bullets[Bullets.length] = tempBullets
Time# = Timer()
EndIf
For m = 0 to Bullets.length step 1
//Bullet Movement
SetObjectLookAt(Bullets[m], GetObjectX(Player), GetObjectY(Player), GetObjectZ(Player), 0)
MoveObjectLocalZ(Bullets[m], 0.03)
//Delete Bullets
RemoveComet = 0
//Collision with Player
ObjectHit1 = ObjectRayCast(Player, GetObjectX(Bullets[m]), GetObjectY(Bullets[m]), GetObjectZ(Bullets[m]), GetObjectX(Player), GetObjectY(Player), GetObjectZ(Player))
If ObjectHit1 = 1
RemoveComet = 1
EndIf
//Collision with Shield
ObjectHit2 = ObjectRayCast(Shield, GetObjectX(Bullets[m]), GetObjectY(Bullets[m]), GetObjectZ(Bullets[m]), GetObjectX(Bullets[m])+ 10,GetObjectY(Bullets[m]) + 10,GetObjectZ(Bullets[m])+ 10)
If ObjectHit2 = 1
Score = Score + 1
RemoveComet = 1
EndIf
//Delete Comets
If RemoveComet = 1
DeleteObject(Bullets[m])
Bullets.remove(m)
EndIf
next m
Print(Bullets.length)
Print( ScreenFPS() )
Sync()
loop
Could you please tell me where I'm wrong? I followed your instruction but it doesn't work.
(You can see that they are not being deleted from the Print)
Cheers