Basically, you're doing vector math without the vectors.
Off the top of my head...
` playerID is the object ID of the player's ship
` enemyID is the object ID of the enemy unit
` markerID is the object ID of the lead point target marker
playerID = 1
enemyID = 2
markerID = 3
` Let's go with the premise that that you use pitch, roll, turn,
` and move by commands to move your enemy around.
`
` The distance that you move the enemy each loop is his speed.
` If you are upgrading the enemy's coordinates, the difference
` between the enemy's old and current position is his speed.
` Just use the absolute value of the delta to determine the
` speed.
` somewhere in your loop...
` FPS is quick and easy, but not as stable as a time based system
` change the numbers to match the speeds desired
enemySpeed# = 10.0 / screen fps()
bulletSpeed# = 100.0 / screen fps()
` somewhere in your loop after the enemy has moved...
` rangeTime is the time it takes a bullet to travel from your
` ship to the enemy
dX# = position object x(enemyID) - position object x(playerID)
dY# = position object y(enemyID) - position object y(playerID)
dZ# = position object z(enemyID) - position object z(playerID)
` I think this is the distance forumla for 3D...
enemyRange# = sqr((dx#*dx#)+(dy#*dy#)+(dz#*dz#))
rangeTime# = enemyRange# / bulletSpeed#
` calculate lead needed
markerOffset# = enemySpeed# * rangeTime#
` sync marker with enemy position
position object markerID, object position x(enemyID), object position y(enemyID), object position z(enemyID)
` sync marker with enemy rotation
rotate object markerID, object rotation X(enemyID), object rotation Y(enemyID), object rotation Z(enemyID)
` project marker in front of enemy
move object markerID, markerOffset#
I hope that makes sense, becuase I can't help you much more than that.
--
TAZ