Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Fps shooting Code Help

Author
Message
kuljot
15
Years of Service
User Offline
Joined: 2nd Jan 2009
Location: sacramneto, ca united states
Posted: 27th Jan 2010 03:21 Edited at: 30th Jan 2010 07:13
Hey guys i am working on an Fps. I searched alot for shooting stuff but most of the stuff didn,t make sense and or work.


I have got code to load the world and pick up the gun. The collision code was taken from the code snippets. Can some one please explain how i can embed shooting code into this, i prefer to shoot boxes from barrel instead of ray casting. Thanks


p.s. i already looked at the fps tutorial and the shooting code didnt make much sense to me so please help.
Edit: Updated the code.

Gateway GT5628 Quad Core Desktop Intel Core 2 Q6600 2.4GHz Quad Core 3072MB RAM / 500GB 7200 SATA II Hard drive DVD RW 18X multi dual NVIDIA GeForce 8500GT ....
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 27th Jan 2010 13:55
Quote: "i prefer to shoot boxes from barrel instead of ray casting"


Ray casting is by far the most accurate method. You can still make it look as if something is moving, but that's just cosmetics.

It's actually really easy too: you just have to find a point directly infront of the gun (for some given distance), and then do the raycast between the gun and this point.

If you need any help, just ask and I or some other forum member will help.

"everyone forgets a semi-colon sometimes." - Phaelax
chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 27th Jan 2010 15:44
If you a looking for something like bullets instead of raycasting, have a look to this piece of code.


cheers.



learning every day
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 27th Jan 2010 17:55
The problem there chafari is that when the object moves, it doesn't literally move through every point in that direction, it just jumps in that direction by a given speed every frame, which means the faster it goes, the more it missed out. If you have a very fast bullet, chances are it won't even hit the target.

"everyone forgets a semi-colon sometimes." - Phaelax
kuljot
15
Years of Service
User Offline
Joined: 2nd Jan 2009
Location: sacramneto, ca united states
Posted: 28th Jan 2010 00:21
well i want to turn this into a simple multiplayer fps. so which would be better for multiplyer. can you guys please give me some examples of ray casting and shooting with raycasting. thanks

Gateway GT5628 Quad Core Desktop Intel Core 2 Q6600 2.4GHz Quad Core 3072MB RAM / 500GB 7200 SATA II Hard drive DVD RW 18X multi dual NVIDIA GeForce 8500GT ....
chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 28th Jan 2010 10:06
@Zotoaster

Ok...that is true...the bullet speed can´t be higher than the bullet long...but it works somehow...it was just an answer to the inquire.

I normally use raycasting and object screen x()...object screen y()...and there´s a big problem with this method because you can hit several enemys at the same time or even behind walls, so we have to check collision .

I have been trying to raycast the shot in a point 1000 units in front and check if there was intersection with some soldats in a queue, and all of them die...I couldn´t fix that when intersect with the first sodat, the second could be happy drinking beer,nooo the beer splash down to the floor...what I mean...I couldn´t stop all soldats dying in the queue.

learning every day
kuljot
15
Years of Service
User Offline
Joined: 2nd Jan 2009
Location: sacramneto, ca united states
Posted: 28th Jan 2010 15:15
well does anyone one have example code of how ot use raycast for shooting thanks for the help so far

Gateway GT5628 Quad Core Desktop Intel Core 2 Q6600 2.4GHz Quad Core 3072MB RAM / 500GB 7200 SATA II Hard drive DVD RW 18X multi dual NVIDIA GeForce 8500GT ....
kuljot
15
Years of Service
User Offline
Joined: 2nd Jan 2009
Location: sacramneto, ca united states
Posted: 29th Jan 2010 05:43
Man no replies, seems like everyones left the forums, i was wondering if any one has examples on how to use ray cast for shooting. Once i learn i can implent it into my code.

Gateway GT5628 Quad Core Desktop Intel Core 2 Q6600 2.4GHz Quad Core 3072MB RAM / 500GB 7200 SATA II Hard drive DVD RW 18X multi dual NVIDIA GeForce 8500GT ....
chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 29th Jan 2010 11:26 Edited at: 29th Jan 2010 11:29
have a look to this code .Maybe you can take something of it

cheers.





learning every day
kuljot
15
Years of Service
User Offline
Joined: 2nd Jan 2009
Location: sacramneto, ca united states
Posted: 30th Jan 2010 05:17 Edited at: 31st Jan 2010 03:25
Hey chafari im trying to implent this into my code, but its not working. It would be realy nice if you coudl help me, ill also continue trying.

This is the position i gave for my crosshair, its aligned with my guns sight. How can i make it so the ray cast is alligned with the ctrosshair. Thanks so much.

I got the code implented in but its still not workign perfectly. The range is very short. Can you please help me to increase the range. By the way i attatched a screen shot of my progrress so far. Almost everyhtings good except the hsooting rnage is extremely small.
No response
Why isn't anyoner responding?

Gateway GT5628 Quad Core Desktop Intel Core 2 Q6600 2.4GHz Quad Core 3072MB RAM / 500GB 7200 SATA II Hard drive DVD RW 18X multi dual NVIDIA GeForce 8500GT ....

Attachments

Login to view attachments
chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 31st Jan 2010 16:19 Edited at: 31st Jan 2010 16:24
Sorry for the delay, but on weekends I use to go out with my wife and family.

last code...there was an error..mmmmmm I don´t know if it was my fault ....in my code I,v got :


And I can´t understand way when I copied and pasted, it was:



The problem is that object position ...was like that: object____position too separated.
So probably you couldn´t see the code....in this code, it shows you how to put the crosshair

If it was the case that you couldn´t see my code, now I hope it must be OK.


cheers.




learning every day
kuljot
15
Years of Service
User Offline
Joined: 2nd Jan 2009
Location: sacramneto, ca united states
Posted: 31st Jan 2010 18:54
Hey chafari i had actually finxed that part of the coce. My only question is which part of the code controls from how far you can shoot. Thanks.

Gateway GT5628 Quad Core Desktop Intel Core 2 Q6600 2.4GHz Quad Core 3072MB RAM / 500GB 7200 SATA II Hard drive DVD RW 18X multi dual NVIDIA GeForce 8500GT ....
chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 1st Feb 2010 11:34 Edited at: 1st Feb 2010 11:40
The distance is:



when we press mouse, the camera move 1000 units ahead and this is the distance....you can decide how far the raycast should go.
Is that right now?

cheers.

learning every day
kuljot
15
Years of Service
User Offline
Joined: 2nd Jan 2009
Location: sacramneto, ca united states
Posted: 3rd Feb 2010 06:48 Edited at: 3rd Feb 2010 07:18
Hey chafari that method doesnt work for me, heres why. I had to change the crosshair to this position to align it with my gun.


nOW THE RAYCAST WAS OFF SO ON THE CAMERAS ORIGINAL POSITON, I ADDED 60 UNTIS TO THE CAMERAS Y POSITION.



sINCE I ADDED 60 UNTIS TO THE Y POSITION THE MOVE CAMERA FURTHER DOESNT INCREASE THE RANGE. sO WHAT AM I ODING WRONG. tHE REASON IM ADDING 60 UNITS TO THE CAMERA Y POSITON IS TO REALIGN THE RAY CAST WITH THE CROSSHAIR.

EDit: Actually what i notcied was the farther i get away from the target i have to raise the crosshair/camera into the air to hit the object. Why is that.And any solutions Thank

Gateway GT5628 Quad Core Desktop Intel Core 2 Q6600 2.4GHz Quad Core 3072MB RAM / 500GB 7200 SATA II Hard drive DVD RW 18X multi dual NVIDIA GeForce 8500GT ....
chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 4th Feb 2010 08:59
I need more code to test


In the example I showed to you, it works perfect....so for any adjusting, I need to se the code.

cheers.

learning every day
kuljot
15
Years of Service
User Offline
Joined: 2nd Jan 2009
Location: sacramneto, ca united states
Posted: 12th Feb 2010 06:55
Hey Chafari,
Everythign else is good now except, when the camera moves forward during shooting, whatever texture is in the way flashes on the screen is there any way to stop this.

Gateway GT5628 Quad Core Desktop Intel Core 2 Q6600 2.4GHz Quad Core 3072MB RAM / 500GB 7200 SATA II Hard drive DVD RW 18X multi dual NVIDIA GeForce 8500GT ....

Login to post a reply

Server time is: 2024-11-16 11:10:11
Your offset time is: 2024-11-16 11:10:11