Projectile Rotation
by James Laker (BurNinG) · in Torque Game Engine · 10/08/2007 (12:50 pm) · 4 replies
Hey, I need your help once again. It should be fairly simple for anyone with Vectors knowlegde.
Let me explain. Im trying to optimise my games networking, by cutting my projectiles. My ships have more than one weapon. So what I did was the following.
Instead of one bullet per projectile I use 2:

The effect should be the same, a little Bandwidth will be saved. Well, thats the idea.
The weapons are merged:

So the idea is simple... BUT, It appears when the weapon projectile is fired, it is never rotated according/relative to the ship, but rather just placed regardless of the rotation.

Now I'm sure someone must've ran into this... (Dont wanna call it a bug)... problem.
So can someone please help me out here. I'm trying to see if it would be better cutting the transmission of the projectiles (BY HALF) over the pipe, but adding that little overhead in calculating the rotation.
So what I need is probably the rotation based on the ship's x-axis. I'm useless when it comes to vector math, so please help.
Let me explain. Im trying to optimise my games networking, by cutting my projectiles. My ships have more than one weapon. So what I did was the following.
Instead of one bullet per projectile I use 2:

The effect should be the same, a little Bandwidth will be saved. Well, thats the idea.
The weapons are merged:

So the idea is simple... BUT, It appears when the weapon projectile is fired, it is never rotated according/relative to the ship, but rather just placed regardless of the rotation.

Now I'm sure someone must've ran into this... (Dont wanna call it a bug)... problem.
So can someone please help me out here. I'm trying to see if it would be better cutting the transmission of the projectiles (BY HALF) over the pipe, but adding that little overhead in calculating the rotation.
So what I need is probably the rotation based on the ship's x-axis. I'm useless when it comes to vector math, so please help.
#2
I renamed them to muzzlepoint0 and muzzlepoint1 for some reason.
Thanks Robert.
10/08/2007 (1:53 pm)
Hmmm... So I should move the Muzzlepoint to the middle of the 2 guns in the DTS (as shown above) I guess. I renamed them to muzzlepoint0 and muzzlepoint1 for some reason.
Thanks Robert.
#3
I moved the Muzzlepoint to the middle (and named it correctly):

and still getting this when I turn:

10/08/2007 (3:35 pm)
Well after testing that it seems this is still not the case.I moved the Muzzlepoint to the middle (and named it correctly):

and still getting this when I turn:

#4
In the second picture above did you perform a "roll" maneuver and then fire?
You are going to have problems with this ( as you see ;)) as you seem to be proceeding far beyond the paradigm of the stock TGE projectiles. For example, the orientation is not sent during pack/unpackData because on the client createOrientFromDir is used in interpolateTick for the attitude. I suspect this means that stock projectiles are flown oriented in a attitude with the forward vector along the current velocity, and the "roll" attitude set via createOrientFromDir to be (essentially) upright. In other words, createOrientFromDir uses the velocity to define a yaw and pitch and then assumes that the best roll= 0. This is fine for firing across a flat-ish terrain. Not so fine for a space game with this particular optimization since zero roll is definitely NOT always best.
You will need to calculate the correct initial orientation, send it, and use it during flight.
The initial orientation is that of your firing ship. You need to use this rather than the stock createOrientFromDir algorithm. As long as your projectiles aren't ballistic, this might be merely adding an additional roll rotation after the attitude from createOrientFromDir is calculated. This way you would only have to calculate and send one parameter (once).
10/09/2007 (8:44 am)
I not familiar enough with your problem to understand the issue from the picture of "and still getting this when I turn:".In the second picture above did you perform a "roll" maneuver and then fire?
You are going to have problems with this ( as you see ;)) as you seem to be proceeding far beyond the paradigm of the stock TGE projectiles. For example, the orientation is not sent during pack/unpackData because on the client createOrientFromDir is used in interpolateTick for the attitude. I suspect this means that stock projectiles are flown oriented in a attitude with the forward vector along the current velocity, and the "roll" attitude set via createOrientFromDir to be (essentially) upright. In other words, createOrientFromDir uses the velocity to define a yaw and pitch and then assumes that the best roll= 0. This is fine for firing across a flat-ish terrain. Not so fine for a space game with this particular optimization since zero roll is definitely NOT always best.
You will need to calculate the correct initial orientation, send it, and use it during flight.
The initial orientation is that of your firing ship. You need to use this rather than the stock createOrientFromDir algorithm. As long as your projectiles aren't ballistic, this might be merely adding an additional roll rotation after the attitude from createOrientFromDir is calculated. This way you would only have to calculate and send one parameter (once).
Torque 3D Owner Robert Blanchet Jr.