Bullets don't shoot right?

Started by
27 comments, last by ParityCheck 20 years, 5 months ago
I think the variable name TargetPos is kind amisleading as the variable being passed to the function is not actually the

target point of the camera. Here is the code that is invoking the load bullet function describes earlier
//on keypress fireaBullet->LoadBullet(CurrentPos.xPos,CurrentPos.yPos,CurrentPos.zPos, CameraLookPos.x, CameraLookPos.y, CameraLookPos.z);


The currentPos is the currnet position & the cameralookpos is actually whats being passed. The camera look pos is constantly

changed in this piece of code in my setupcamera function
D3DXMATRIX matrixCamera;D3DXVECTOR3 CameraPos(CurrentPos.xPos, CurrentPos.yPos, CurrentPos.zPos);	LookPos.x = (float)sin(LookAtAngle);LookPos.y = sinf(LookAtUpAngle);LookPos.z = (float)cos(LookAtAngle);	CameraLookPos = LookPos + CameraPos; //add the two vectorsD3DXMatrixLookAtLH(&matrixCamera,&CameraPos, &CameraLookPos, &D3DXVECTOR3(0.0f,1.0f,0.0f));	//Which way is Up???		lpDevice->SetTransform(D3DTS_VIEW, &matrixCamera);	D3DXMATRIX matrixProject;//setup the field of view, aspect ratio, near clipping plane, far clipping planeD3DXMatrixPerspectiveFovLH(&matrixProject, D3DX_PI/4,1.0f,1.0f,500.0f);//apply the transformationlpDevice->SetTransform(D3DTS_PROJECTION, &matrixProject);//Set Z buffering enabledlpDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);//set lightinglpDevice->SetRenderState(D3DRS_LIGHTING, TRUE);


About using 2 translation matrices I myself don''t get it as to why 2 matrices are needed. by using just one matric my bullet

just hangs around in midair until the loop terminates. Actually on pressing the fire key and invoking the code above the

following function in my game renderloop is initiated i.e. this is where my bullet actually moves.

//RENDER GAME LOOPif(aBullet->IsLoaded())//GetBulletStat()==LOADED)//if the bullet is loaded {							// Shoot	i++;	aBullet->MoveBullet(i);}


the bullet actually moves on each loop of the render game function. The isLoaded function returns true only after the fire

button has been pressed. The parameter i being passed to the movebullet function is just an increment on the number of

iterations the loop has made. upon reahing the maximum iteration the bullet is removed and variables cleared to original.

this sorta started off as a buildup on some tutorials. The bullet is actually dependent on the render loop for the ''chaneg in

distance'' if I may be allowed to say so . for some reason could the problem be in the render loop on the setcamera function

...
Keep coding..
Advertisement
Your camera code? Don''t you mean everyone''s basic, obvious, and simple camera code? Oh, but it must be yours? Cause you are the only one who does this... wow, that is funny.
uh yeah that too so any suggestions guys. actually I was wondering whether I'm making a goof up in the lookpos and cameralookpos vector variables or so. It seems like a simple problem gone to herculean proportions. I really do need to get this working guys any suggestions please

[edited by - ParityCheck on November 15, 2003 1:44:49 AM]
Keep coding..
I've tried my best to make my bullet move in the direction its aimed at but nothing seems to work.

What could be the problem in my code guys? Its posted on the previous page.

I'd like to know if there are any other techniques on implementing this. Or rather what would be the easiest and sure fre way of implementing bullets shooting in using DX8 and VC6. I'd be ready to start this bullet shooting from scratch. help and suggestion would be most greatly appreciated guys

[edited by - ParityCheck on November 15, 2003 4:37:35 AM]
Keep coding..
quote:I''d like to know if there are any other techniques on implementing this. Or rather what would be the easiest and sure fre way of implementing bullets shooting in using DX8 and VC6. I''d be ready to start this bullet shooting from scratch. help and suggestion would be most greatly appreciated guys


Have you looked at the pseudocode I posted?


Mariano Ruggiero
Lead Programmer
ONIRIC GAMES
I've understood the pseudocode though but I'm wondering whether I may be calculating my 'camera look at' position wrong. here is the code which I'm using to calculate my camera lookat point.

D3DXMATRIX matrixCamera;D3DXVECTOR3 CameraPos(CurrentPos.xPos, CurrentPos.yPos, CurrentPos.zPos);	LookPos.x = (float)sin(LookAtAngle);LookPos.y = sinf(LookAtUpAngle);LookPos.z = (float)cos(LookAtAngle);	CameraLookPos = LookPos + CameraPos; //Cameralookpos is supposed 2 be the cameras looking target D3DXMatrixLookAtLH(&matrixCamera,&CameraPos, &CameraLookPos, &D3DXVECTOR3(0.0f,1.0f,0.0f));			lpDevice->SetTransform(D3DTS_VIEW, &matrixCamera);	


The variables CameraPos are the cameras current position & the Camera LookPos is the camera view target point and these are what I'm passing to my bullet function .
My basic matrix transformation concepts and trigonometry are real messed up man and had to reach this code after a bit of help though, do you see anything wrong with it?


[edited by - ParityCheck on November 15, 2003 10:02:58 AM]
Keep coding..
This is starting to get creepy. I double checked tha lgo and fixed to code to have it output contiinuously the bullets position i.e the position being passe to the matrixtranslate function. The bullet positional variables are incrementing pretty much properly but the bullet is STILL going in a direction contrary to what the transform being made!! Upto the point where I call the bullets render function everything seems hunky dory. ?? My bullet cube is actually implemented using index buffers, you don''t suppose that could be causing trouble?
Keep coding..
quote:Original post by ParityCheck
This is starting to get creepy. I double checked tha lgo and fixed to code to have it output contiinuously the bullets position i.e the position being passe to the matrixtranslate function. The bullet positional variables are incrementing pretty much properly but the bullet is STILL going in a direction contrary to what the transform being made!! Upto the point where I call the bullets render function everything seems hunky dory. ?? My bullet cube is actually implemented using index buffers, you don''t suppose that could be causing trouble?

I''d be shocked and amazed, except for the fact that I mentioned all this back on the first page, right after you posted your cleaned up code...
:D its real funny if you look at it, I rechecked the code and like you were right man all along (not like I had any doubts or so ) I ean I had the speed on my bullet set to so low that I couldn''t tell whether it was moving or not. Guess wisdom comes real slow to me .. ain''t that funny :D Thanx for the help man, ..

There is just one teeny little issue though, that my bullet now shoots on to the target (thats 90% of the job done) but he keeps shooting from different angle i.e sometimes the top left of the scrren, or bottom right, or middle top depending on what angle my camera is rotating or yawed upon :S what could be causing this any ideas guys
Keep coding..

This topic is closed to new replies.

Advertisement