Ill be adding in how to throw projectiles like nades and shoot slow objects like raockets into the FPS tut soon, but just ask Antidote how "soon" soon is and you'll begin to seem less faithful
Got some projects due this week so I dont have time to work on it for a few days atleast.
As for theory;
- Position the object to be projected at the coordinate you wish (the gun, the user's head, the user's position, whatever)
- Rotate the projectile to be equal to the projecter's angle (the gun, the user, whatever again)
- Begin moving the object forward at the pace you want
Pretty simple, taking it further;
- To add some weight, define a variable, say, Fall#, as a positive value, then use the POSITION OBJECT command to position the projectile at it's x, it's y plus the Fall value, and it's z, then just decrease the fall value by whatever rate you want each sync. This will at the beginning move the projectile upward for a bit, but then the variable will become positive and will move the projectile downward, it's smooth if you give the rate of decrease of Fall a small value.
Even more so;
- Delete or hide or reposition the bullet object when it collides with anything or is too far away
- Check for collision using whatever method you like, i'd use collision boxe's since it doesn't have to be too acurate, but intersection checks or sphere collision could work too.
- Then just handle the variable appropriately, resetting the Fall value, decreasing Ammo, damaging living objects the projectile collides with, etc.
For explosives...
- If it's a nade you could use a timer then when the timer reaches the required time create a large sphere at the nade position and damage anything touching the sphere
- or -
- If its a rocket do the same without the timer
- Maybe add some forces onto the explosion, like moving the object hit backwards, the speed of movement would depend on the distance to the explosion core.
Hope it helps, like I said I'll be adding it to the tutorial next hopefully since I'm planning on incorperating multiple weapons next (shotgun, rocket launcher, grenade, knife, sniper, smg, pistol)
If you haven't seen the tutorial yet, the link is:
http://www.ruccus.net/Tutorial.htm
From there you'll find the main tutorial, the current code, a screenshot (not recent sorry), a link to the forum that started it all, some notes and soon a compiled .exe for those not with DBP on their computer at the time.
Oh and the tutorial is for DBP.