Adding bullet tracers
by Blake LaPierre · in Torque Game Engine · 07/23/2004 (9:32 pm) · 5 replies
I'm trying to add tracers to projectiles, this is what I have right now in Projectile::renderObject(...) :
This works fine when I'm shooting straight ahead. However if I angle the gun upwards more than 45 degrees the line will start at the projectile and end at the position of the character that shot the projectile.
I'm thinking that it is a problem with the inequality in my if statement that causes the line to be drawn when it shouldn't be.
Any ideas?
Point3F end = mCurrVelocity;
end.normalize(mDataBlock->tracerLength);
if (mSourceObject && (mCurrPosition - mSourceObject->getPosition()).lenSquared() > (mDataBlock->tracerLength * mDataBlock->tracerLength)) {
glLineWidth(0.5);
glBegin(GL_LINES);
glColor3f(1.0,1.0,0.55);
glVertex3f(mCurrPosition.x, mCurrPosition.y, mCurrPosition.z);
end = mCurrPosition - end;
glVertex3f(end.x, end.y, end.z);
glEnd();
glLineWidth(1.f);
}This works fine when I'm shooting straight ahead. However if I angle the gun upwards more than 45 degrees the line will start at the projectile and end at the position of the character that shot the projectile.
I'm thinking that it is a problem with the inequality in my if statement that causes the line to be drawn when it shouldn't be.
Any ideas?
#2
Is there something special about first person mode? I thought it was pretty much the same as third person just moved ontop of the model?
07/24/2004 (5:12 pm)
I did some testing with two computers in the same game and it appears that the problem only happens in first person mode. If I push tab, although it could just be the model blocking my view, everything seems normal. When you watch a player shooting from the other computer everything looks normal. On both computers though when in first person mode and the gun angle is above aprox. 45 degrees there will sometimes be tracers that seem to start at the player's position and goto the bullet. Is there something special about first person mode? I thought it was pretty much the same as third person just moved ontop of the model?
#3
07/24/2004 (7:25 pm)
Maybe you're drawing the line very close to the camera so it looks like it's shooting straight up, but really isn't?
#4
I posted it as a resource for anyone that is interested because I know this is used in a quite a few games and have been looking for someone who had added it to Torque already but couldn't find it so I gave in and did it myself :)
It hasn't been approved yet, but here's the link: www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=6116
07/24/2004 (9:20 pm)
Well I finally got it to work after approaching it in a slightly different way. Here's the actual drawing code I used: Point3F end = mCurrVelocity; end.normalize(mClampF((mCurrPosition - mInitialPosition).len(), 1.0, mDataBlock->tracerLength)); glLineWidth(0.5); glBegin(GL_LINES); glColor3fv(mDataBlock->tracerColor); glVertex3f(mCurrPosition.x, mCurrPosition.y, mCurrPosition.z); end = mCurrPosition - end; glVertex3f(end.x, end.y, end.z); glEnd(); glLineWidth(.1f);
I posted it as a resource for anyone that is interested because I know this is used in a quite a few games and have been looking for someone who had added it to Torque already but couldn't find it so I gave in and did it myself :)
It hasn't been approved yet, but here's the link: www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=6116
#5
07/24/2004 (9:48 pm)
Glad to hear you got it fixed!
Associate Kyle Carter