z_man is right. For fast projectiles where you're not supposed to "see" the projectile, you should use ray casting.
However, to continue on your problem, if you're having a projectile that is supposed to be seen (like a rocket launcher) you have to use arrays. There's no other way around it because you usually need more information than just the object's rotation and position (like some sort of life, damage, acceleration, etc.)
First you create a custom type with all the data that you might need. An example would be
type tRocket
obj as integer : `Contains the object number of the rocket
life as integer : `The remaining life before auto-destroying
damage as float : `The damage dealt by the rocket
v as float : `The speed of the rocket
acc as float : `The acceleration of the rocket (boost)
RocketType as integer : `The type of the rocket (like 1 = normal, 2 = heat-seeking, ...)
endtype
Then you create an array that will contain the data of all the rockets in the game
dim Rockets(0) as tRocket
I chose size 0 because there is no rocket yet.
Upon creating a rocket, you add it to this array by using
array insert at top Rockets()
Rockets(1).obj = freeobject()
clone object Rockets(1).obj, RocketPrototype
Rockets(1).life = 100
Rockets(1).damage = 3.0 + 0.1 * rnd(10)
Rockets(1).v = 0.1
Rockets(1).acc = 0.01
Rockets(1).RocketType = 1
or if you want to insert every new rocket at the end of the list:
array insert at bottom Rockets()
a = array count(Rockets())
Rockets(a).obj = freeobject()
clone object Rockets(a).obj, RocketPrototype
Rockets(a).life = 100
Rockets(a).damage = 3.0 + 0.1 * rnd(10)
Rockets(a).v = 0.1
Rockets(a).acc = 0.01
Rockets(a).RocketType = 1
After that, when you want to manipulate the rocket, you use a normal for-next loop.
`Updating all rockets
a = array count(Rockets())
`You should note we're NOT looping from 1 to a. If we did that, then if we deleted a rocket, the next rocket would be skipped.
`Also, we would have to call array count() every loop to avoid an array out of bounds error.
for i = a to 1 step -1
`Accelerate the rocket
Rockets(i).v = Rockets(i).v + Rockets(i).acc
`Store old rocket position
obj = Rockets(i).obj
ox# = object position x(obj)
oy# = object position y(obj)
oz# = object position z(obj)
`Move to new position
move object obj, Rockets(i).v
`Raycasting from old to new position (yes I'm a Sparky's collision DLL fan)
col = SC_rayCast(0, ox#, oy#, oz#, object position x(obj), object position y(obj), object position z(obj), obj)
if col > 0
`Explode!
`Apply total destruction to level!
`etc.
`Remove rocket from list
delete object obj
array delete element Rockets(), i
endif
next i
And that should be all for controlling all your rockets.
The method I described has the disadvantage that adding and removing elements from an array is pretty slow. But it has the advantage that the only limit on the number of rockets in your game is the number of rockets you can load in your memory.
Sven B