PDA

View Full Version : How would i make a gun?



rlmergeuser
04-28-2012, 09:25 PM
How could i make a weapon that looks like a gun and fires when i press the right trigger and the bullet/projectile do damage or destroy a target?

rlmergeuser
04-28-2012, 09:56 PM
anyone?

rlmergeuser
04-28-2012, 10:10 PM
There's the FPS example if you press start in the editor and go to example tracks. It's very complex and the easiest way would probably be just to see what they did there.

FlowRiderX
04-28-2012, 10:21 PM
http://www.blogmond.com/2007/12/04/10-ways-how-to-build-a-homemade-gun/

rlmergeuser
04-28-2012, 10:35 PM
There's the FPS example if you press start in the editor and go to example tracks. It's very complex and the easiest way would probably be just to see what they did there.
that just gives the example of the workings of the camera, no guns are in that model

i've been thinking about how to fire projectiles for a while, and aside from the exact maths i'd need i've come up with something that should work

- the bullets will need to be stored in some inaccessible and non viewable area of the map.
- to fire the bullet, you will need to know the characters position and rotation in each axis.
- when you press fire, the bullet will be instantly teleported to your position and rotation
- with some trigonometry (that i havent worked out) you could use a linear data source to affect the position of the bullet. the trigonometry will change the angle the bullet moves to the angle you are facing
- once the bullet has collided with something, or has travelled a certain distance, it should teleport back to the storage warehouse
- to enable multiple bullets to be fired quickly you will need to have several identical bullets with that animation sequence set up to a counter which will cycle through each bullet, and back to the first one once the last bullet has been fired

one thing i have thought of is that your own bullets would have to have custom hit detection which excludes everything of your own character, but includes everything else