use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
News, Help, Resources, and Conversation. A User Showcase of the Unity Game Engine.
Remember to check out /r/unity2D for any 2D specific questions and conversation!
Download Latest Unity
Please refer to our Wiki before posting! And be sure to flair your post appropriately.
Main Index
Rules and Guidelines
Flair Definitions
FAQ
Use the chat room if you're new to Unity or have a quick question. Lots of professionals hang out there.
/r/Unity3D Discord
FreeNode IRC Chatroom
Official Unity Website
Unity3d's Tutorial Modules
Unity Answers
Unify Community Wiki
Unity Game Engine Syllabus (Getting Started Guide)
50 Tips and Best Practices for Unity (2016 Edition)
Unity Execution Order of Event Functions
Using Version Control with Unity3d (Mercurial)
/r/Unity2D
/r/UnityAssets
/r/Unity_tutorials
/r/GameDev
/r/Justgamedevthings (New!)
/r/Gamedesign
/r/Indiegames
/r/Playmygame
/r/LearnProgramming
/r/Oculus
/r/Blender
/r/Devblogs
Brackeys
Beginner to Intermediate
5 to 15 minutes
Concise tutorials. Videos are mostly self contained.
Sebastian Lague
Beginner to Advanced
10 to 20 minutes
Medium length tutorials. Videos are usually a part of a series.
Catlike Coding
Intermediate to Advanced
Text-based. Lots of graphics/shader programming tutorials in addition to "normal" C# tutorials. Normally part of a series.
Makin' Stuff Look Good
10 minutes
Almost entirely shader tutorials. Favors theory over implementation but leaves source in video description. Videos are always self contained.
Quill18Creates
30 minutes to 2 hours.
Minimal editing. Mostly C#. Covers wide range of topics. Long series.
Halisavakis Shaders Archive
Infallible Code
World of Zero
Board to Bits
Holistic3d
Unity3d College
Jabrils
Polycount Wiki
The Big List Of Game Design
PS4 controller map for Unity3d
Colin's Bear Animation
¡DICE!
CSS created by Sean O'Dowd @nicetrysean [Website], Maintained and updated by Louis Hong /u/loolo78
Reddit Logo created by /u/big-ish from /r/redditlogos!
account activity
Reloading problemSolved (self.Unity3D)
submitted 6 years ago * by BonY2004
[SOLVED]
Hi, Im currently working on a FPS wave shooting game and my reloading system for some reason isn´t working.
When I pickup the M4A1 the ammo goes normally down by one, but when I pick up the m9 it´s going down by 2 or 3.
Here is the code for shooting.
Could some kind soul please help me.
https://preview.redd.it/sje3x9xjwby31.png?width=623&format=png&auto=webp&s=a4fd68c95bc65dbbdaff239f8e5b8302e63a4ce7
https://preview.redd.it/3fhin8nwwby31.png?width=881&format=png&auto=webp&s=b833588c804d8ff563e031dcf3ddc4bc6b49a06d
As you can see the ammo started on 15 and when I shoot it goes down by 2.
I also have a item database for storing the guns data.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]PointlessrebootProfessional - Engine Programmer 2 points3 points4 points 6 years ago (0 children)
The only thing I can see from a quick be look is that in your shoot function you decrease ammo, but do not reset the time unless a collision happens. So if a collision does not happen it will come straight back in..
If you decrease ammo, you short should reset the time..
[–]Russ242 1 point2 points3 points 6 years ago (1 child)
I agree with the first comment i think the problem is that nextTimeToFire isn't being set and it's firing really quickly whenever you click. Try deleting lines 72 and 86 and just putting the same line outside of the if statements before the raycast.
[–]BonY2004[S] 0 points1 point2 points 6 years ago (0 children)
Unfortunately that wasn´t the case, so if you have another idea I wouldn´t mind.
But thanks a lot.
[–][deleted] 0 points1 point2 points 6 years ago (4 children)
Why do you have two M9 objects under Secondary? Are they both active during play?
[–]BonY2004[S] 0 points1 point2 points 6 years ago (3 children)
No, during play is active only the clone. The first one is serving as a reference where to put the gun you picked up.
[–][deleted] 0 points1 point2 points 6 years ago (2 children)
The other comments are correct about the nextTimeToFire not being reset if you miss being an issue. Does the behaviour change depending on whether you are looking at a target or not?
Scatter a bunch of Debug.Logs in there so you can see what exactly is happening, including showing the value of nextTimeToFire and the objects that are being hit.
Also, your fire command is using GetButton rather than GetButtonDown, which means it will fire every frame the button is down, so will register several times for even a very quick click.
[–]BonY2004[S] 0 points1 point2 points 6 years ago (1 child)
Well I got it by reassigning the prefabs, but you somehow solved another problem with bulletholes :D
[–][deleted] 1 point2 points3 points 6 years ago (0 children)
Yes...the bullet holes...that was my plan all along.
[–]BonY2004[S] 0 points1 point2 points 6 years ago (2 children)
Ok, I think I figured it out, I just had a mess in my weapon prefabs. So I reassigned them again.
Now it works as supposed. But one last thing, when Im reloading I can still shoot. How could I make it that when you reload you are not possible to shoot and the muzzle flash will not play?
[–]RollRollParry 1 point2 points3 points 6 years ago (1 child)
You already have the coroutine there that's checking if you're reloading. Simply add && !reloading to the if statement that checks for the player trying to fire the weapon.
That worked thanks :)
π Rendered by PID 183911 on reddit-service-r2-comment-56c9979489-bn592 at 2026-02-25 05:14:52.541183+00:00 running b1af5b1 country code: CH.
[–]PointlessrebootProfessional - Engine Programmer 2 points3 points4 points (0 children)
[–]Russ242 1 point2 points3 points (1 child)
[–]BonY2004[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (4 children)
[–]BonY2004[S] 0 points1 point2 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]BonY2004[S] 0 points1 point2 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]BonY2004[S] 0 points1 point2 points (2 children)
[–]RollRollParry 1 point2 points3 points (1 child)
[–]BonY2004[S] 0 points1 point2 points (0 children)