Fleet of space ships

Blitz3D Forums/Blitz3D Programming/Fleet of space ships

BerndWill(Posted 2004) [#1]
In my space game, I want to have a fleet of ships (with the same mesh). Do I really have to "loadMesh" or "copyMesh" for every ship or is there a chance to link the ships to the same original mesh ?

Thanks, Bernd


Perturbatio(Posted 2004) [#2]
see copy entity, however, bear in mind the issues with the command as well (explained in the docs).


BerndWill(Posted 2004) [#3]
So, the fleet models are copies anyway ?
No reference possibility ?

Thanks, Bernd


RiverRatt(Posted 2004) [#4]
You should look at using types and copy entity or copy mesh.
Using Types you can create as many ships as you want, by sticking them in a for each next loop. If you don't like types use an array.


MSW(Posted 2004) [#5]

So, the fleet models are copies anyway ?
No reference possibility ?



erm...what do you mean?

from the Blitz docs for copyentity:
Creates a copy of an entity and returns the handle of the newly created copy. This is a new entity instance of an existing entity's mesh! Anything you do to the original Mesh (such as RotateMesh) will effect all the copies. Other properties (such as EntityColor, Position etc.) since they are 'Entity' properties, will be individual to the copy.



first you loadmesh() the ship model...then for each ship in the fleet you copyentity...say you have 50 ships in the fleet...so you do something like this:

DIM ships(49)

shipref = Loadmesh("ship.3ds")

For i = 0 to 49

 ships(i) = Copyentity (shipref)

Next


now you can moveentity(), positionentity(), rotateentity(), Turnentity(), colorentity(), etc...with each ship to make them individualy do what you want...move them around in fleet formation, etc..

You can then create a pivot and parent all or just part of the ships to it...then by moveing the parent pivot around, all the children ships move with it.

Only one mesh (shipref) is stored in memory...all of the ships are instances of that mesh...you can do what you want with the instances, and it only effects that particular instance...but if you change shipref, then all of the instances are changed as well.