hello this is my first question (and not the last one i will be asking). I am new to unity and I have started making a game. i was wondering if anyone had a script for the gun (to shoot,set ammo amount, display ammo, mussle flash and sound). sorry i am asking for so much but even one of these would help alot or even a tutorial.
thank you for your help.
I don’t have already done codes, but here are guidelines :
- The shoot part is done by getting a direction, instantiating a bullet, using rigidbody.AddForce. You could also only instantiate the impact, which position is found by a Raycast.
- The ammo amount, just and int decreasing for every shot.
- Pickable ammos, this is done with triggers. Try the Lerpz tutorial, it’s very helpful.
- Sound is a clip played by an audioSource, audio.Play();
- Flash could be a light with halo turned off and on again very fast.
Good luck !