Shooting, Simple Spread, and Bullet Trails in a ScriptableObject-Based Gun System | Unity Tutorial

Learn how to create a ScriptableObject-based gun system from scratch for your game!
In this video, which is part 1 of a much larger gun system series, we'll create 3 ScriptableObjects to control our Gun, Bullet Trails, and Shoot Configurations for 2 types of guns. Specifically, we're doing "Hitscan" or Raycast shooting in this video.
In this video I DO NOT cover the Impact System: • Impact Effects with Sc... you can check out that video for the full explanation for how that works
That’s for the SurfaceManager and ImpactType both. If you’re not interested in using that system for impacts, feel free to just remove that code! Everything will still work!
PlayerIK is a very simple demo script implemented solely for the demo. As I mention in the video, this will be covered in the future, so you can skip that part for now, or check out the project on GitHub to see that naïve implementation.
In this series you'll learn how to make a configuration-driven gun system with ScriptableObjects that will be able to have:
⚫ Hitscan Guns - Covered in THIS VIDEO!
⚫ Projectile Guns
⚫ Simple Bullet Spread - Covered in THIS VIDEO!
⚫ Complex Bullet Spread
⚫ Reloading
⚫ Attachments
⚫ Animated Models
⚫ Simple Impact Damage
⚫ Damage Effects such as burning, freezing, explosions, etc...
⚫ And even more!
👨‍💻 As always, all code from this video is available on GitHub: github.com/llamacademy/script...
💸 Ongoing sales 💸
⚫ See all active asset sales on the Asset Store: assetstore.unity.com/?on_sale...
⚫ Save 25% off your first Asset Store Order: prf.hn/click/camref:1101l9QvC...
⚫ Save up to 50% on NEW Assets: assetstore.unity.com/?new_sal...
📚 References
⚫ Unity 2021 Object Pool: • Unity 2021 Object Pool...
⚫ Impact System: • Impact Effects with Sc...
⚫ Scriptable Objects, Explained: • ScriptableObjects, Exp...
⚫ Lerping Fundamentals: • Lerping Fundamentals -...
❤ Believe in LlamAcademy's mission and have received value from the videos? Become a Patreon Supporter or KZread Member:
⚫ Patreon: / llamacademy
⚫ KZread Member: / @llamacademy or click the Join button on any video
📱 Let's stay connected
KZread: / llamacademy
Patreon: / llamacademy
Facebook: / llamacademyofficial
Twitter: / thellamacademy
TikTok: / llamacademy
Instagram: / llamacademy
----
Most tutorials come from knowledge gained making survival.llama.software Llama Survival - a top-down zombie survival shooter for Android and iOS.
I also have some Unity Assets: assetstore.unity.com/publishe...
Some links may be affiliate links, which at no additional cost to you, gives me a small portion of the purchase.
#unitytutorial #tutorialtuesday #gamedev #tutorial #unity #llamacademy #gamedevelopment
Chapters:
00:00 Intro & Overview
01:43 Why ScriptableObjects over Prefabs?
02:35 GunType.cs
02:48 ShootConfigScriptableObject.cs
03:28 TrailConfigScriptableObject.cs
04:26 GunScriptableObject.cs - Variables
05:45 GunScriptableObject.cs - Spawn()
06:33 GunScriptableObject.cs - CreateTrail()
07:15 GunScriptableObject.cs - Shoot()
09:14 GunScriptableObject.cs - PlayTrail()
10:47 Design Discussion
11:27 GunScriptableObject.cs - Adding Impact Effects with SurfaceManager
12:22 Become a Supporter
12:53 PlayerGunSelector.cs
14:28 PlayerAction.cs
15:08 Creating & Configuring the Gun ScriptableObjects
19:48 Demo
21:00 Closing Thoughts on this Implementationver

Пікірлер: 243

  • @maxg5196
    @maxg5196 Жыл бұрын

    Some of this I have implemented myself, but never before with Scriptable Objects, which sounds like will allow for much more customizability and expandability. Excited for this series!

  • @Blinkers2007GameDev
    @Blinkers2007GameDev11 ай бұрын

    Thanks man! The create tail and render trail funcion and the variabels was very useful for creating the perfect trail. It's always better controlling it with the code. Learnt alot and I could now use this in my own game to create good looking bullets. Thanks!!!!!!

  • @brickch4pel
    @brickch4pel11 ай бұрын

    One of the best things about your tutorials is finding out about new/old things that I never even knew about in all my time of using unity. (case in point, native unity Object Pools?!?!?!?! This is so cool!!!)

  • @K.Z007
    @K.Z00711 ай бұрын

    Great, what a brilliant brain you have to create such sophisticated system and you been so kind to share with us. Thank you a lot mate. You are amazing.

  • @LlamAcademy

    @LlamAcademy

    11 ай бұрын

    Wow thank you for that! It made me smile 😊

  • @peche87_gameDev
    @peche87_gameDev Жыл бұрын

    Great content as usual! Looking forward the next videos on this serie! :)

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    Thanks 🙏 I am too 🙂

  • @AmgedAlfakih
    @AmgedAlfakih Жыл бұрын

    This an amazing weapon system, it'll be an amazing starting point to add more advanced stuff like gravity or bouncing

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    Thanks 🙏! Gravity will come with projectile-based weapons in the future. I covered bouncing bullets before here: kzread.info/dash/bejne/eZ-H1rlxXbSbgJM.html I wasn’t planning to cover it in here, but that’s an interesting idea to consider to have it all in one place.

  • @AmgedAlfakih

    @AmgedAlfakih

    Жыл бұрын

    @@LlamAcademy my goal is to add gravity to the raycast, I mean a noob I'll learn a lot if i do it

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    You can do that, but usually bullets have relatively low mass and high velocity which makes the normal hitscan ray cast “good enough” of a simulation. If you really want to add it, you can follow the concept of this video: kzread.info/dash/bejne/aqF7vKSSo7a-k7Q.html and it will give you the result you’re looking for.

  • @paulberry3359
    @paulberry3359 Жыл бұрын

    So looking forward to this series !!!

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    Me too 😁! This is one topic area I feel is underserved and needed!

  • @jaulloa21
    @jaulloa21Ай бұрын

    I like how this complex system is organized for a noob that would be frustrated otherwise

  • @geri4367
    @geri4367 Жыл бұрын

    Hell yeah. This is amazing :D Once the series is over, something similar for an ability system (think League of Legends for example) would be sick. I've been doing some research lately and there isn't much valuable content about it. Maybe it's a good challenge and opportunity Anyways, thanks for your awesome work!

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    ❤️! That’s a great idea! I have a real life use case for that, so maybe once I get some time to play with it and see the challenges I can put together a series on it!

  • @user-gv6fi7bg1f
    @user-gv6fi7bg1f Жыл бұрын

    you are awesome ,please keep the brilliant work❤❤

  • @LlamAcademy
    @LlamAcademy Жыл бұрын

    In this video I DO NOT cover the Impact System: kzread.info/dash/bejne/nYhmvNqjfdi6j5c.html you can check out that video for the full explanation for how that works! That’s for the SurfaceManager and ImpactType both. If you’re not interested in using that system for impacts, feel free to just remove that code! Everything will still work! PlayerIK is a very simple demo script implemented solely for the demo. As I mention in the video, this will be covered in the future, so you can skip that part for now, or check out the project on GitHub to see that naïve implementation. Edit: Aiming IK is covered in depth here: kzread.info/dash/bejne/lZybrrSjg8TViMY.html

  • @Maskeowl

    @Maskeowl

    Жыл бұрын

    where i can get that too? should i download it ? isthere tutorial for it ?

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    Yes there is a tutorial, that’s linked above. It also has the GitHub repository in the description of the video. This video also has a GitHub repository that includes that code.

  • @Maskeowl

    @Maskeowl

    Жыл бұрын

    @@LlamAcademy OHHH i read ffew times but i cant see git hub thanks man very cool

  • @pritiguptaraina3083
    @pritiguptaraina30832 ай бұрын

    ive not even finished this series yet and i know its gon be good (everything i need for fps)

  • @durvids474
    @durvids474 Жыл бұрын

    Great stuff as always!

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    Much appreciated 🙏

  • @potatoguy9653
    @potatoguy9653 Жыл бұрын

    Bro, i'm tryna make an fps game, and I haven't been able to find a good video for this kind of stuff for weeks. You, my dear friend, are a god send

  • @brianrussell5789
    @brianrussell57899 ай бұрын

    Thanks for this dude!

  • @Inf4mousKidGames
    @Inf4mousKidGames8 ай бұрын

    For those of you wanting to use this for an FPS, configure the player camera to be the raycast start point, from what I've heard making the camera the start point fixes a lot of inconsistencies with aiming

  • @evangeli-on7034

    @evangeli-on7034

    4 ай бұрын

    Could you, please, explain how to do it?

  • @pritiguptaraina3083

    @pritiguptaraina3083

    Ай бұрын

    @@evangeli-on7034 too late probs but just switch the camera to that thing

  • @user-yx5bf7dp4s
    @user-yx5bf7dp4s Жыл бұрын

    Hi! I would like to say that this series of tutorials has been very well done and very helpful. And I have a question which is when I implemented this gun system into my project, I found that the trails that shoot out are biased to move upwards and look a bit unnatural in first-person view, is there any way to modify it to make the trail become more straight or fall slowly?

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    The spread is based on your defined Vector3 (Simple) or Texture. If you feel the "upward spread" is too much, you can play with whichever option you have to lower the variance in that direction. Usually a gun does recoil up, so I would expect that to be one of the primary ways it does recoil 🤔

  • @shirujsjs578
    @shirujsjs57810 ай бұрын

    Does the weapon work well for FPS? Or adjustments have to be made. Thanks for making such a complete tutorial.

  • @LlamAcademy

    @LlamAcademy

    10 ай бұрын

    Yeah it should work for FPS. I saw a few people are using it in FPS scenarios successfully

  • @donaldsimmons4370
    @donaldsimmons43706 ай бұрын

    Great series. Learning a lot about scriptable objects. I do have one question however. In the repository there are a number of "Editor" scripts that aren't explained in the video and it appears the SO scripts won't function without them? thx

  • @LlamAcademy

    @LlamAcademy

    6 ай бұрын

    You do not NEED any of the editor scripts for them to work, but they make it easier, faster, and more convenient to set stuff up. How the custom inspectors are done are covered in these: kzread.info/dash/bejne/Zatty7qNZtreZco.html & kzread.info/dash/bejne/n6OM2LCjZ7S7eKg.html Each video in this series has its own branch in the github repository so if you want to see just what was done in video 1, check out branch "part-1"

  • @legendsmb-pw6mv
    @legendsmb-pw6mv8 ай бұрын

    In GunScriptableObject.cs, why is the TriangleIndex set to 0 directly in the following line? SurfaceManager.Instance.HandleImpact( HitCollider.gameObject, HitLocation, HitNormal, ImpactType, 0 ); Won't this result in incorrect impact results if there are multiple submeshes?

  • @Toeknuckles
    @Toeknuckles Жыл бұрын

    awesome tutorial man! I've been looking for this exact kinda tutorial since like last week! 😅 Got a noob question for you, Is there a way to apply damage to a gameobject based on where the bullet trail ends up actually hitting? Just trying to see if I can simulate projectile based weapons but with raycasts so players could effectively dodge bullets if they get out of the way of the bullet trail before it makes contact with them? 🤔

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    You could do something like Physics.OverlapSphere or OverlapBox after the trail reached the target location to be sure the object is still within range of error to count as a hit. Assuming you have fast moving objects, by the time the trail got there the object could have moved too far away to count as hit and you could continue the trail as though it missed altogether

  • @InfernoCreator
    @InfernoCreator Жыл бұрын

    Amazing! | Just asking if you have any tutorial to zoom in with the gun? If you do please reply to me.

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    I do not but that is on my list for this series

  • @Healz4Life
    @Healz4Life Жыл бұрын

    Hey @LlamAcademy I was hoping to get the github version of this project working, as it was awesome to see it graciously provided and I was looking to compare my current system which has been built upon from your previous tutorials. I just had one problem, it doesn't seem to be explained how I go about importing Unity Particle Pack into the project without destroying the settings. Also awesome production quality on these videos B)

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    Hi! Great question, and a common one. The Unity particle pack can be imported without overriding settings if you deselect all of the project settings files (they’re like the last ones). If you only select the folder about Effect Examples you will only get the particle systems, materials, and textures

  • @Healz4Life

    @Healz4Life

    Жыл бұрын

    @@LlamAcademy Thanks for the quick reply! Got it working great now as long as the hilarious aiming isn't caused by me, I could see this whole looking down+aim bull in a china shop movement mode working quite well if implemented as a feature XD CHARRRGE hahaga. As it's a common question it could be nice to have a quick explanation added to the github's "Quickstart", including updating materials. Looking forward to seeing how far this series goes!

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    😁 the movement and aiming is not particularly well implemented. It was a quick hack job just to get something there while we implemented the core “gun functionality”. Coming soon - accurate crosshairs! Movement still will be crazy while aiming but the aim will be right. Sorry! I meant to say as well, I will update the readme with that info!

  • @jarvinvruizeeslao
    @jarvinvruizeeslao2 ай бұрын

    Awesome tutorial! Quick question, I've used the system for a RTS game, but I can't seem to figure out why does the duplicated unit detects an enemy, the original shoots. Any thoughts? Thanks in advance!

  • @LlamAcademy

    @LlamAcademy

    Ай бұрын

    Sounds like maybe the ScriptableObjects aren't cloned properly and all are using the original?

  • @maitrykotak3703
    @maitrykotak37032 ай бұрын

    the problem i am having is i am having a virtual camera that follows character positioned at characters back....show only characterss back portion will show now during swipe code of look functionality of starter asset its rotating in every angle so may characters side and front portion is visisble ...is it possible that any swiping character also rotate on camera direction...so only back portion of character will be seen..please help

  • @ToughAndGrittyOpGrunts
    @ToughAndGrittyOpGrunts Жыл бұрын

    Hi great tuturial ! which part do you show how to set up the IK script or do you have a seperate tuturial🙂

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    I do not have the IK tutorial yet, but you can check out the project from GitHub and review this implementation as a quick and dirty get started point!

  • @ToughAndGrittyOpGrunts

    @ToughAndGrittyOpGrunts

    Жыл бұрын

    @@LlamAcademy Brilliant thank you very much 🙂

  • @adventuretuna
    @adventuretuna Жыл бұрын

    Wouldn't the GunType enum prevent you from updating the game over-the-air (like you mentioned in 1:50)? Adding a new gun type would require you to update the code and thus require a new build. Since you're using it as a unique identifier, a string or integer might be a better fit. Just need to remind the designer to make the identifiers unique (or write an editor script to automatically fix them). Otherwise pretty great tutorial. Straight to the point and very little to no fluff.

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    Yes you are correct! In the final section I discuss ways to solve that problem. Specifically, I talk about how you could use the "Name" parameter on the GunScriptableObject to match against in place of GunType. Edit for some more context: For most developers, that's not going to be within the scope of what they'll implement. Typically I don't like "magic strings" that have significant meaning, so I implemented the GunType to have a declarative way to match the guns for the majority of users, and in the end of the video I talk about how you can support the over the air updates by using the Name as a "magic string"

  • @adventuretuna

    @adventuretuna

    Жыл бұрын

    @@LlamAcademy Alright I missed that part. The real solution to avoid magic strings would be to have an editor tool that automatically populates the identifiers with Guid or something similar but that's way out of this video's scope. Might be an interesting topic in the future though. I feel like editor scripting in general is not discussed a lot.

  • @MarekNijaki
    @MarekNijaki Жыл бұрын

    Awesome video! Just wish explanation would be little bit slower. My brain had to switch to second gear to keep with the pace of video. Other than that great job!

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    It's always a fine line to walk between "too fast" and "quit droning on and on". I'm generally a fast paced person so I guess it comes through in the videos sometimes 😅

  • @okandikkulak8057
    @okandikkulak8057 Жыл бұрын

    Do you have a weapon manager video? I don't think there exists one on youtube. For choosing and equiping a weapon before the match starts, or as we spawn like in Valorant.

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    I’m thinking that in this series I may cover some kind of gun selector!

  • @albertum_o2
    @albertum_o2 Жыл бұрын

    I couldn't finish my code relying this turorial, but thanks, it's really cool video. I faced mistake when I tried make ObjectPool(CreateTrail) - now we need to provide a second argument "actionOnRelease". I can approximately imagine how to do it, but anyway it's a bit complicated to me).

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    Hmm... the 2021 Object Pooling system should not require you provide the secondary argument. If you want to understand more about the 2021 Object Pooling system you can check out my full tutorial on that: kzread.info/dash/bejne/rK2u06OYc7PgYqg.html For any shooting system, I highly recommend using an Object Pool to eliminate garbage and keep your game running smoothly

  • @albertum_o2

    @albertum_o2

    Жыл бұрын

    @@LlamAcademy Thank you for your answer! I know that I need to dig deeper. I'll definitely check it out to fully understand this topic.

  • @LostAngel175
    @LostAngel1752 ай бұрын

    Very Modularity, I like it.😂

  • @bqnny1233
    @bqnny1233 Жыл бұрын

    Question: I love this implementation of yours because it's very flexible and can be built on top very easily, But I do have a problem. Most games have a gun-changing system or a gun equip system(the one where you can change the gun you are currently using at runtime). However your system doesn't support that, how could I modify it to let me do that? Sorry for the lack of proper punctuation and grammar, English isn't really my primary language.

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    Swapping active guns may be a good topic to add to the series because it seems to be a highly requested topic. You can do a similar process to what is done in the PlayerGunSelector, or even reuse the logic from Awake when the player presses a button. If you have a game with a layout similar to Counter-Strike where you press 1,2,3,4 to swap weapons, you would just catch the key press, update the "Gun" to whatever is for that key, destroy the old gun, and re-run the Awake logic. Of course it would look better tying in animations, but that concept should get you started!

  • @bqnny1233

    @bqnny1233

    Жыл бұрын

    @@LlamAcademy Thanks for the basic Idea, I'll try to implement it and if you don't mind, may I ask what is the next part after part 6 of the series going to cover?

  • @shubhamdhumal7578
    @shubhamdhumal75788 ай бұрын

    this work well can we do this for mele combat swords and hand

  • @MaximilianPs
    @MaximilianPs28 күн бұрын

    Awsome but were I find the tutoria to make the StarterAsset as a Third Person Shooter? 😅😅

  • @mystocity
    @mystocity8 ай бұрын

    I also still have playtrail does not exist in the current context should that still be there

  • @J0ELPC
    @J0ELPC8 ай бұрын

    Hey LlamAcademy, i love your video. however i have one small issue when adding public ImpactType ImpacType; i get the error CS0246: The type or namespace name 'ImpactType' could not be found (are you missing a using directive or an assembly reference?). is surface manger a addon i need to add to my unity project???

  • @LlamAcademy

    @LlamAcademy

    8 ай бұрын

    Check out pinned comment & description!

  • @kamron4825
    @kamron4825 Жыл бұрын

    In the GunSo you have ImpactType and SurfaceManager, which appear to not be a part of the unity engine. where did you make those or get those classes/objects from? Same with PlayerIK in PlayerGunSelector

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    👋 Hi! PlayerGunSelector we implemented in this video. When I talk about SurfaceManager / ImpactType I mentioned it was covered in another video (that’s linked in the description). The full project is on GitHub so you can view all those files. A better version of the PlayerIK will be done in a future video. As I said, It was really just for the demo to look nicer with the hands actually on the gun

  • @joaodias8824

    @joaodias8824

    Жыл бұрын

    I don't think that you're going to see this, but if you did, how did you fix this?

  • @kamron4825

    @kamron4825

    Жыл бұрын

    @@joaodias8824 sadly I never fixed it

  • @joaodias8824

    @joaodias8824

    Жыл бұрын

    @@kamron4825 if I figure it out I'll let you know

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    Hello. As I said above you can find the SurfaceManager and ImpactType on the GitHub github.com/llamacademy/scriptable-object-based-guns/tree/main/Assets/Scripts/Surface%20Manager If you would like to understand how those are created, you can check out the associated tutorial: kzread.info/dash/bejne/nYhmvNqjfdi6j5c.html These can be completely skipped and ignored if you do not want to use that impact system without any additional loss in functionality. PlayerIK is also in the repository: github.com/llamacademy/scriptable-object-based-guns/blob/main/Assets/Scripts/PlayerIK.cs, but again I don’t recommend relying on this because I just quickly put it together without much thought. Later in the series we’ll probably review a better implementation. In this video I covered PlayerGunSelector at 13:00. You can always check the chapters at the bottom of the video to see each section.

  • @MaverickPlayer
    @MaverickPlayer Жыл бұрын

    Hi, I'm using your ScriptableObjectBased Gun System on FPS game. When I walk and shoot at the same time, the bullet trail came from behind the gun(kind of behind camera). I tried to fix it by changing the startPosition of Trail at the begginingof the BulletTrail Coroutine, but it was same result. And also, when walk left, walk right and shoot at the same time, bullet trail start from air too, Do you have any idea how to prevent from happening these. Thank you for your great tutorial.

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    Hey! I think someone else asked about that in the comments of one of the videos, but I can't seem to find it now. In most games, this "problem" exists because the player and the gun are moving. Even though we spawn correctly from the barrel of the gun, that was at a snapshot in time. I looked into several other AAA games to see if this was something of an oversight that I had or what the deal was. It turns out even AAA games either: have this problem, or mitigate it by having extremely short bullet trails. The solutions I see are: 1. Leave it alone and have this "problem" - it can be mitigated somewhat by having smoke or something that comes out of the barrel afterwards to mask the effect. 2. Have very short lived bullet trails - player can't see the "problem" 3. Bind the start position constantly to the barrel of the gun (this results in "bending" of the trail which may not be desirable).

  • @avgchoobafan
    @avgchoobafan7 ай бұрын

    i know this is a relatively old video but i wonder how can i change so instead of using the GunType enum to hold different guns, instead serve as a way to differentiate shooting modes, something like: enum GunType{ SemiAutomatic, Automatic, Burst } I think i should have different Shoot functions and use a Switch to select the shooting mode depending on what GunType the Gun is assigned to, but i'm afraid that having 3 functions with almost identical code is a bad way to do this, so i don't know how to approach this

  • @LlamAcademy

    @LlamAcademy

    6 ай бұрын

    In my game to differentiate between burst and automatic I applied a modifier to the gun to adjust the mode, "number of bullets per shot", and increased the delay between shots by 3x. In the "Shoot" function all I did was check if it was "burst" and started a coroutine to spawn 3 bullets over the course of several frames instead of 1 in a single frame. The outcome is minimal changes to "Shoot" and the rest of the gun system remained unchanged. Later on in this Gun Series I cover a modifier and attachment system that can help achieve this effect (around part 9 & 10). I didn't do Semi-Auto in my game, but I think that is possible to handle by just tracking if the player has at least 1 frame where they were not pressing "shoot" then proceed with the current code flow

  • @hoangminhnguyen9571
    @hoangminhnguyen95713 ай бұрын

    Does this project differentiate which kind of interaction to use for which weapon? Like how a glock is semi, an m4 is automatic, a laser gun is charge/release

  • @LlamAcademy

    @LlamAcademy

    3 ай бұрын

    Not really. The gun system supports any of these, but the player interaction with the gun system is left to the implementer. If you would like these “fire mode”s I’d recommend to add that to the ShootConfigSO and read it on your “PlayerInput” and use that to determine if the gun.tick() should be called

  • @BrunoBozicB
    @BrunoBozicB Жыл бұрын

    The "ParticleSystem" named "ShootSystem", what is it? is it a particle system nested somewhere on the gun prefab? is it for the muzzle flash? Could you please point me to the video that explains the muzzle flashes and/or the "ShootSystem"? Thanks in advance for the information.

  • @BrunoBozicB

    @BrunoBozicB

    Жыл бұрын

    Found a brief mention of this here: kzread.info/dash/bejne/lX1np5mYlpqafaQ.html if anyone is interested...

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    Hey! The ParticleSystem named ShootSystem is gathered at the time of spawning the gun into the world. I set it up in the code around time 6:20. Around 16:25 I talk about the prefab configuration of the glock and m4. I didn't talk too much about the positioning of it, but you should place it where you want the bullets to spawn, so close to the tip of the muzzle. The assumption here is the muzzle flash and the bullet spawn point can be the same place In your other comment, in that video we drag references in the Inspector, which I tried to avoid here, instead I'm opting to pick it up automatically on Spawn.

  • @jeremywieland714

    @jeremywieland714

    Жыл бұрын

    @@LlamAcademy I downloaded your github repo and opened it in the same unity version. Looks like the MuzzleFlash01 is having issues (missing Prefab with guid: numbers-blah-blah. Sadly it keeps me from trying out your system :( ... Thanks for the tuts though, very nice!

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    @@jeremywieland714 Did you import the Unity Particle Pack after checking out the GitHub?

  • @jeremywieland714

    @jeremywieland714

    Жыл бұрын

    @@LlamAcademy That was it thanks!

  • @whysl
    @whysl Жыл бұрын

    I don't know how to fix that problem... Can anybody help? GunScriptableObject.cs(9,9): error CS0246: The type or namespace name 'ImpactType' could not be found (are you missing a using directive or an assembly reference?) PlayerGunSelector.cs(16,10): error CS0246: The type or namespace name 'PlayerIK' could not be found (are you missing a using directive or an assembly reference?)

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    Hi 👋. The impact system won’t be covered in this series because it was covered in this video: kzread.info/dash/bejne/nYhmvNqjfdi6j5c.html The full projects for all my videos are available on GitHub, so you can download those scripts from here: github.com/llamacademy/scriptable-object-based-guns (links also in description). Since this video is part 1 only, you may change the branch to “part-1” to only see what you see here. Good luck!

  • @billybillington5340
    @billybillington5340 Жыл бұрын

    Hi, I am trying to follow this great tutorial, but at 11:34 you use (SurfaceManager) and it is showing up as an error for me. I do not know where in the video this class was created, hope you can get back to me on this. :)

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    Please see pinned comment

  • @10saltedalmonds17
    @10saltedalmonds17 Жыл бұрын

    Hello, I am having an error with this line of code remainingDistance -= TrailConfig.SimulationSpeed * Time.deltaTime; It says that TrailConfigurationScriptableObject does not contain a definition for SimulationSpeed. Is there any import or something that i missed? Any ideas of how to fix this?

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    Seems like on the trail config you missed a step. Double check that section and what you have defined versus what is in the GitHub repository: github.com/llamacademy/scriptable-object-based-guns/tree/part-1

  • @Sam4Progress
    @Sam4Progress3 ай бұрын

    21:00 so my question here is, I've tried putting assets in the Resources Folder before, and then created a folder hierarchy within it, and couldn't reach the hierarchy. What do I need to do to reach the hierarchy or is that what addressable resolves? This is effectively my second week in Unity and I am trying to learn C# principles as well as how Unity functions, so forgive me if this question is obvious, or incomplete.

  • @LlamAcademy

    @LlamAcademy

    3 ай бұрын

    For resources folder you can load with the path name to the file without “Resources”. Resources are bundled on build, so if you include everything there, you can easily reference them. Addressables allow you to extend the game without needing to rebuild the whole game.

  • @Sam4Progress

    @Sam4Progress

    3 ай бұрын

    @@LlamAcademy awesome, I saw some videos, that were not beginner level, and it seemed like that was the next step in my programming journey after the basics! Thanks for confirming that!

  • @pritiguptaraina3083
    @pritiguptaraina3083Ай бұрын

    I decided to cut out InverseKinematics since i'm using Unity Personal, so i really can't do it. If there is a workaround, please tell thee.

  • @LlamAcademy

    @LlamAcademy

    Ай бұрын

    There's no limits to functionality within Unity. You can be on Personal and still use this fully.

  • @vuxenn
    @vuxenn Жыл бұрын

    When i try to change active gun while game is running it says "The variable ShootSystem of GunScriptableObject doesn't exist anymore." what can i do to change my gun while game is running

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    That's a more complex answer than I can probably reasonably do in a comment. I am planning on adding a video in the series about weapon swapping because that is a very commonly requested topic!

  • @DeLaBerni
    @DeLaBerni6 ай бұрын

    Hey one question which Third Person Controller Asset do u use ?

  • @LlamAcademy

    @LlamAcademy

    6 ай бұрын

    I use the Unity Starter Assets Third Person Controller assetstore.unity.com/packages/essentials/starter-assets-third-person-character-controller-urp-196526 It's free!

  • @medopizza9
    @medopizza99 ай бұрын

    the Object pool keeps showing this error: "The type or namespace name 'ObjectPool' could not be found (are you missing a using directive or an assembly reference?)"

  • @LlamAcademy

    @LlamAcademy

    9 ай бұрын

    We’re using the Unity 2021 object pooling system here. As long as you are on 2021 LTS or higher you should be able to add “using UnityEngine.Pool;” at the top of the script and it should work for you.

  • @Jemmeh
    @Jemmeh Жыл бұрын

    Thank you for the video! Small bit of feedback the music is a tad loud and it makes it harder to understand you. If anything I'd prefer no music, especially any time there's an editor open. I've had to rewind a good bit 😅

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    Thank you for the feedback, I thought I had it at a low enough volume to not be distracting but apparently not! I will keep that in mind in the future.

  • @Jemmeh

    @Jemmeh

    Жыл бұрын

    @@LlamAcademy Appreciate you hearing me out!

  • @SergioGonzalez-pq3gc
    @SergioGonzalez-pq3gc10 ай бұрын

    Hello, does anyone know in what video does he implement the IKs for the gun holding animations? Thanks in advance!

  • @LlamAcademy

    @LlamAcademy

    10 ай бұрын

    #12 Aiming with Inverse Kinematics (IK) and Animation Rigging | Gun Series 12 | Unity Tutorial kzread.info/dash/bejne/lZybrrSjg8TViMY.html

  • @SergioGonzalez-pq3gc

    @SergioGonzalez-pq3gc

    10 ай бұрын

    @@LlamAcademy thank you, good sir! Have a nice day!!!

  • @oakleysands-my1kt
    @oakleysands-my1kt4 ай бұрын

    why wont my private ObjectPool TrailPool; work this is the error Assets\Scriptys\GunScriptableObject.cs(21,13): error CS0246: The type or namespace name 'ObjectPool' could not be found (are you missing a using directive or an assembly reference?)

  • @oakleysands-my1kt

    @oakleysands-my1kt

    4 ай бұрын

    pls help🤔

  • @LlamAcademy

    @LlamAcademy

    4 ай бұрын

    Which version of Unity are you on? The object pooling API was introduce in the 2021 LTS.

  • @maitrykotak3703
    @maitrykotak37034 ай бұрын

    trails is creating nicely but they are created far from pistol,,,,not from the pistol...is there any solution?

  • @LlamAcademy

    @LlamAcademy

    4 ай бұрын

    Are you assigning their start position to the gun particle system as soon as you spawn them?

  • @seafood3237
    @seafood323710 ай бұрын

    I'm getting this error: " NullReferenceException: Object reference not set to an instance of an object at UnityEngine.Rendering.Universal.UniversalRenderPipeline.SetupPerFrameShaderConstants () [0x00089] in :0 at UnityEngine.Rendering.Universal.UniversalRenderPipeline.Render (UnityEngine.Rendering.ScriptableRenderContext renderContext, System.Collections.Generic.List`1[T] cameras) [0x00065] in :0 at UnityEngine.Rendering.RenderPipeline.InternalRender (UnityEngine.Rendering.ScriptableRenderContext context, System.Collections.Generic.List`1[T] cameras) [0x0001c] in :0 at UnityEngine.Rendering.RenderPipelineManager.DoRenderLoop_Internal (UnityEngine.Rendering.RenderPipelineAsset pipe, System.IntPtr loopPtr, UnityEngine.Object renderRequest) [0x00046] in :0 " when i'm playing on build

  • @LlamAcademy

    @LlamAcademy

    10 ай бұрын

    This seems like it an error related to URP 🤔 not sure

  • @mat3iav52
    @mat3iav52 Жыл бұрын

    hey amazing video and i have followed but i have a problem, when i click "create

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    Usually that’s because the gun scriptable object was not converted from “: MonoBehaviour” to “: ScriptableObject” or the [CreateAssetMenu] tag is missing, or improperly defined (such as copy/paste issue with multiple SO with the same path)

  • @mat3iav52

    @mat3iav52

    Жыл бұрын

    @@LlamAcademy i did everything correct as you said but still doesnt work i grabbed the code from your github so its copy pasted, i dont know what to do now, if you are ok on communicating on discord so i can show you a picture of the error. it would be the easiest method.

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    Okay. Send me a message llamasoftware#5070

  • @kivivikix

    @kivivikix

    3 ай бұрын

    @@LlamAcademy Hi, what was the issue on this one?

  • @kivivikix

    @kivivikix

    3 ай бұрын

    oh, found it.

  • @migueldc6845
    @migueldc6845 Жыл бұрын

    What just happend. 😭Im learning C# for about under a year now ... what must i do to become so heckin' good like you! Im amazed, honestly.

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    😅 thank you for the compliment. Just keep working, practicing, and learning. You will get better!

  • @isagunenc4484
    @isagunenc4484 Жыл бұрын

    I did the same thing you did in the video, but it didn't work, only the gun was on the player's body. I deleted them with impcat type , player ik or something . Can you post the player ik script file? and can you solve this problem of mine please because we will enter the game contest

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    The full project is on GitHub. You can check out the whole thing working together. Link’s. In the description

  • @mdekram6792
    @mdekram6792 Жыл бұрын

    I don't know how to fix the problem. Please somebody help me Null reference not set to an instance of an object GunScriptableObject.Shoot().cs:246

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    Hmm… from this video GunScriptableObject does not have 246 lines of code. Can you please review your implementation compared to the part-1 branch? github.com/llamacademy/scriptable-object-based-guns/blob/part-1/Assets/Scripts/Gun/GunScriptableObject.cs

  • @l.g5390
    @l.g539010 ай бұрын

    So if I not implement the part with the Surface Manager (the vid in the info) i have no visuals… so I have to watch the video and implement the surface manager etc right?

  • @LlamAcademy

    @LlamAcademy

    10 ай бұрын

    You will not have impact effects, but you can also just pull the surface manager off GitHub. It’s included in this repository as well as the dedicated surface manager video repository.

  • @l.g5390

    @l.g5390

    10 ай бұрын

    Thanks a lot

  • @l.g5390

    @l.g5390

    10 ай бұрын

    ( this shouldn't be a link

  • @emilbejstrup4956
    @emilbejstrup4956 Жыл бұрын

    I am a new developer so please bare with me. If I used this approuch in a multiplayer game, wouldnt I run into trouble if two players used the same gun as they would share the clipsize?

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    No, there would not be an issue there. Each player would have their own copy of the ScriptableObject that is being manipulated in that case!

  • @bbrainstormer2036
    @bbrainstormer203610 ай бұрын

    Hey! This tutorial looks great, but when I download it from Github, it keeps giving me errors. I think the issue is with the MuzzleFlash particle system in the gun previews

  • @LlamAcademy

    @LlamAcademy

    10 ай бұрын

    Did you import the Unity Particle Pack after cloning from GitHub?

  • @bbrainstormer2036

    @bbrainstormer2036

    10 ай бұрын

    @@LlamAcademy Yeah, but they don't work with URP Edit: the render pipeline converter solves the issue

  • @LlamAcademy

    @LlamAcademy

    10 ай бұрын

    @bbrainstormer2036 awesome to hear!

  • @SageSLAMS
    @SageSLAMS Жыл бұрын

    I am getting errors saying Assets\GunScriptableObjects.cs(135,50): error CS1002: ; expected Assets\GunScriptableObjects.cs(119,15): error CS1513: } expected Assets\GunScriptableObjects.cs(119,15): error CS1002 ; expected Assets\GunScriptableObjects.cs(52,48): error CS1001: identifier expected Can you put the scripts in a GitHub, or type it in the Description because i have no idea what this means :/

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    It is on GitHub and the link is in the description

  • @walkingdead8331
    @walkingdead83318 ай бұрын

    is it possible to do trail without object pooling because i am in 2020 and i cannot access unity object pool

  • @LlamAcademy

    @LlamAcademy

    8 ай бұрын

    I would really recommend to use some form of object pool for this. In my earlier videos when 2021 wasn't out I made a simple one you can use (video: kzread.info/dash/bejne/mKd4p8Gmf5e4irA.html code: gist.github.com/llamacademy/e3ed9e647b2c703d698a809d00a112a8 ) If you don't want to, you can use Instantiate/Destroy instead of getting objects from the pool and disabling them.

  • @DeLaBerni
    @DeLaBerni10 ай бұрын

    Hey what is this SurfaceManager ? I dont have that ..

  • @LlamAcademy

    @LlamAcademy

    10 ай бұрын

    It's how we manage impact effects. That was covered in a separate video and has a dedicated github repo. More details in description and the pinned comment.

  • @joaodias8824
    @joaodias8824 Жыл бұрын

    I don't know if you're still answering comments on this video, bit if you do, after the Player gun selector script it gives me an error, the type or namespace name "PlayerIK" could not be found". I've looked in the GitHub that you provided but even with your code it still happened. Help would be appreciated

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    Seems like you are missing the PlayerIK Script: github.com/llamacademy/scriptable-object-based-guns/blob/main/Assets/Scripts/PlayerIK.cs Cloning the repository fresh I did not get the error. Can you try to make sure you don't have any other compiler errors that prevented it from picking up the script? This is not mandatory and I don't even really recommend to use it in your production game. You can skip all code related to PlayerIK and still have the shooting working. It will just not have the hands tied to the gun.

  • @joaodias8824

    @joaodias8824

    Жыл бұрын

    @@LlamAcademy Thanks, I'll test it out

  • @shadowartz9968
    @shadowartz996810 ай бұрын

    Mr. Chris sorry to bother you but where on github can I download all the most recent scripts for this shooting project. I thought I downloaded all the scripts but the code has errors in surface manager and a few other places

  • @LlamAcademy

    @LlamAcademy

    10 ай бұрын

    Hi! If you download the project from github.com/llamacademy/scriptable-object-based-guns and follow the setup instructions there (downloading Unity Particle Pack for example) it should work with no errors. Each video has a branch with exactly what you saw on that video. For this one, at the top left where you see a dropdown that says "main" you can change that to "part-1" and it will reflect exactly where this video ended. If you download the latest "main" and it has some errors, can you share those exact error messages along with your version of Unity so I can troubleshoot those? It should be very easy to get working.

  • @shadowartz9968

    @shadowartz9968

    10 ай бұрын

    @@LlamAcademy Thank you for your help that worked.

  • @subequalpushup
    @subequalpushup10 ай бұрын

    tryed to put bullet prefab in but it wont let me

  • @gaminggorillla

    @gaminggorillla

    10 ай бұрын

    help

  • @LlamAcademy

    @LlamAcademy

    10 ай бұрын

    Did you assign the bullet script to your prefab?

  • @il_bert0354
    @il_bert0354 Жыл бұрын

    Hi, i'm getting this error "MissingReferenceException: The variable shootSystem of SO_Gun doesn't exist anymore." after a few seconds on play mode, but i don't know how to fix it, somebody can healp me?

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    Sounds like maybe your gun prefab doesn't have a Particle System as a child of it

  • @il_bert0354

    @il_bert0354

    Жыл бұрын

    @@LlamAcademy thx for the fast answer, the problem was that i has the particle system, but my dumb-ass did not called it in the gun script…thx again

  • @InvisaPotion
    @InvisaPotion Жыл бұрын

    Yo I added the trail but sometimes the trail for a bullet will just shoot off to the side and stretch out, is there any way to fix this?

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    Hmm.... usually the only way I can get that to happen is if I don't wait a frame before reactivating the TrailRenderer. Can you compare what you have to what is on Github: github.com/llamacademy/scriptable-object-based-guns/tree/part-1 ? And if you get the same behavior with that, show me a short video of what is happening and what configuration you are using?

  • @kivivikix

    @kivivikix

    3 ай бұрын

    @@LlamAcademy I'm having this same issue, the trail shoots to the last shot position and the new shoot position at the same time resulting in 2 rays. Sometimes there is a ray that shoots at totally random direction. I have no idea how to fix that.

  • @kivivikix

    @kivivikix

    3 ай бұрын

    instance.transform.position = StartPoint; I was missing this line

  • @francescogerlin8006
    @francescogerlin8006 Жыл бұрын

    Can i transform this to use it for a doom clone game?

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    I don’t see why not 🙂

  • @GameDevs_Life
    @GameDevs_Life8 ай бұрын

    does anyone know how to fix surfacemanager error ? , it would really helpfull

  • @LlamAcademy

    @LlamAcademy

    8 ай бұрын

    Please check pinned comment

  • @skyvence8088
    @skyvence8088 Жыл бұрын

    Hello, I got some issue with the code. I got those error while trying to shoot. Unity Error : NullReferenceException: Object reference not set to an instance of an object GunScriptableObject.Shoot () (at Assets/Game/WeaponSystem/GunScriptableObject.cs:44) PlayerAction.Update () (at Assets/Game/WeaponSystem/PlayerAction.cs:15) I search on the github part 1 and i get the same issue while using the code on the github. I really don't know what cause this. I am using Unity 2021.3.20f1.

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    You can see on line 44 of GunScriptableObject that it is trying to reference the "ShootSystem". The only way for that to not be defined is if the Gun prefab you have chosen does not have a Particle System as a child!

  • @skyvence8088

    @skyvence8088

    Жыл бұрын

    @@LlamAcademy It's working fine now ! TY

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    Awesome! 😎

  • @NolanCoe
    @NolanCoe Жыл бұрын

    Anybody else having some trouble with "The type or namespace name 'PlayerIK' & 'ImpactType' & 'SurfaceManager' could not be found"?

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    Yes. Please see pinned comment

  • @abcdgamingandcreations2104
    @abcdgamingandcreations21046 ай бұрын

    I have an issue when im firing the trail is instantiation from the ground

  • @LlamAcademy

    @LlamAcademy

    6 ай бұрын

    Make sure you have the particle system at the tip of the gun and when you are spawning the bullet to set the spawn point to be at the same point!

  • @abcdgamingandcreations2104

    @abcdgamingandcreations2104

    6 ай бұрын

    @@LlamAcademy yea thanks I fixed

  • @NebbyProductions
    @NebbyProductions Жыл бұрын

    This is a Very interesting concept of Guns in Unity. I really appreciate it. Though... I would love to know how it's possible to load the gun in "PlayerGunSelector" Through a PlayerPref. Would it be better to give each GunScriptableObject it's own Index based on an Int or would it work if I save a PlayerPref String Value in any script in my project and load it back within the start method of PlayerGunSelector? As Example: Script: MainMenuSelectGunExample.cs If(blah blah blah clicked on this) { PlayerPref.SetString("Gun_A"); } Then in Script: PlayerGunSelector.cs public void Start() { GunScriptableObject gun = PlayerPrefs.GetString("Gun_A"); } Is that possible? I understand the basic principle of this way of implementing guns, though I don't quite understand the way of actually loading them in yet. Though I really like this video and you really made everything pretty clear. It's just me overthinking everything again... probably. I appreciate you help

  • @gamernabilalabadi6240
    @gamernabilalabadi6240 Жыл бұрын

    can some one help me? in 11:30 he use SurfaceManager by mine script dont work

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    The SurfaceManager is done in another video, linked in description. You can skip that if you do not need impact effects at this time.

  • @adm0151
    @adm01512 ай бұрын

    Surface Manager and Impact Type are not declared. What to do? HELP!!!

  • @LlamAcademy

    @LlamAcademy

    2 ай бұрын

    Check out the description 🙂

  • @adm0151

    @adm0151

    2 ай бұрын

    @@LlamAcademy Oh, I get it. Thanks

  • @dekenfnombre9143
    @dekenfnombre9143 Жыл бұрын

    wb knife throwing projectile?

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    You could probably handle that here as well with a low rate of fire and customized animation. Projectiles are covered in Part 6 of this series!

  • @MASTONGAMES
    @MASTONGAMES Жыл бұрын

    I want to do this with netCode... I didn't find anything about it...

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    There's generally 2 approaches with networked games: 1 do the Raycast on the server based on server-synchronized positions of players / guns and send an RPC/message to clients that the shot was fired from point X to point Y and have the clients only handle the rendering. 2 do the raycast on the client and send a message to the server that it hit something and have the server validate if that's reasonable (that's the hard part 😉- you can skip this but it makes it really easy to cheat). #1 is harder to cheat with, #2 "favors the shooter" which can feel more responsive.

  • @MASTONGAMES

    @MASTONGAMES

    Жыл бұрын

    @@LlamAcademy grateful

  • @Byteezexe
    @Byteezexe10 ай бұрын

    What do i do to get the surface manager?

  • @LlamAcademy

    @LlamAcademy

    10 ай бұрын

    You can check it out from this project or the dedicated Surface Manager github. Those are all linked in the description.

  • @Byteezexe

    @Byteezexe

    10 ай бұрын

    ok thanks@@LlamAcademy

  • @vergincore
    @vergincore Жыл бұрын

    I keep getting errors saying "The name 'instance' does not exist in the current context" did I miss something?

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    “Instance” should be capitalized. But for the surface manager, it’s not covered in this video. You can copy/paste the Surface Manager scripts from the repo: github.com/llamacademy/scriptable-object-based-guns/tree/main/Assets/Scripts/Surface%20Manager Or, to understand the implementation you can watch that video: kzread.info/dash/bejne/nYhmvNqjfdi6j5c.html

  • @vergincore

    @vergincore

    Жыл бұрын

    @@LlamAcademy alright, thank you! I just kind of assumed such a generic word like Instance would already be used by unity!

  • @vergincore

    @vergincore

    Жыл бұрын

    @@LlamAcademy alright one more question, got those errors fixed by going through the impact video, but now i get the error "UnassignedReferenceException: The variable ShootSystem of GunScriptableObject has not been assigned."

  • @ginoantenucci6424
    @ginoantenucci6424 Жыл бұрын

    11:38 I don’t have the surface manager nor the impact type

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    Hi. There’s several comments around this one. In this video I DO NOT cover the Impact System: kzread.info/dash/bejne/nYhmvNqjfdi6j5c.html you can check out that video for the full explanation for how that works. In there we create the SurfaceManager and ImpactType. If you don’t care yet about impact effects, you can safely skip those and you will still be fine 💪

  • @ginoantenucci6424

    @ginoantenucci6424

    Жыл бұрын

    @@LlamAcademy yeah just saw that😅 great vid very good system

  • @gtoonz7081
    @gtoonz7081 Жыл бұрын

    I keep getting error on the surface manager script

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    Hi. The surface manager is not covered in this video and can be ignored, or you can watch the video about it to learn more: kzread.info/dash/bejne/nYhmvNqjfdi6j5c.html

  • @scottmontgomery528
    @scottmontgomery528 Жыл бұрын

    Hey, thank you for the tutorial, I am new to unity and have tried to follow this for a couple of hours but have hit an issue, I'm not sure if it's due to me not using your SurfaceManager and Impact Manger, I have followed along and typed the code out exactly although I'm receiving this error while attempting to fire; NullReferenceException: Object reference not set to an instance of an object GunScriptableObject.Shoot () (at Assets/Scripts/Weapons/GunScriptableObject.cs:39) PlayerAction.Update () (at Assets/Scripts/Weapons/PlayerAction.cs:12) I've since tried copying your code from github and replacing the 6 files creating in this tutorial but I had the exact same error so I think I have missed something in the setup in Unity but I'm at a loss as to what if you have any advice I'd appreciate it. I've also tried importing Unitys particle system as recommended to another commenter but it didn't change anything.

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    Can you give me the code at line #39 of GunScriptableObject.cs? From the repository on part 1 that is not a line that can give any error. If it is: Vector3 shootDirection = ShootSystem.transform.forward + .... It is important that your Gun model has a Particle System as a child of it and is positioned at the tip of the barrel. This is where all bullets will spawn. If you do not do this, ShootSystem will be NULL and give you that error. We assign ShootSystem on Setup() by doing: ShootSystem = Model.GetComponentInChildren(); which requires that the Particle System is a child of the instantiated gun prefab model.

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    Let me know if you run into any issues after doing that!

  • @anonymoussloth6687
    @anonymoussloth6687 Жыл бұрын

    How do games make gun skins? Sometimes, the skins make the gun very different than the original gun. Example: valorant. Skins make guns have different trails, recoil, textures, even different models of the same gun

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    In the most recent videos in the series, we build out the systems to enable exactly what you're talking about. For a Skin, you can apply the same concept as any other modifier, where it can also apply a different shader or material to the gun.

  • @anonymoussloth6687

    @anonymoussloth6687

    Жыл бұрын

    @@LlamAcademy hi, thanks for your reply. But what about guns that have completely different mesh for skins? Like in valorant, many guns have skin specific components

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    Sounds likely they just have a different prefab with the same base model and each skin can have fancy other attachments or different materials

  • @kostariev_vadim
    @kostariev_vadim7 ай бұрын

    Funny glitch on KZread, I see only one like that I put.

  • @ChadGatling
    @ChadGatling9 ай бұрын

    You need to stop doing everything uprfront. It is soo hard to figure out what is actually happening when you just spend 10 mins rattling off a bunch of code. Make it by following the logic of the functionality instead of setup then implementation. Start with a basic implementation and then add complexity on top of that. You might as well just have people download the files because this isn't really teaching the concepts from the ground up it is just rote memorization of how to do a very specific type of thing.

  • @masterhumanprimitive4040

    @masterhumanprimitive4040

    6 ай бұрын

    I agree with you about this 😢

  • @TheSkarri
    @TheSkarri5 ай бұрын

    Dayum, this nerds got biceps xD

  • @LlamAcademy

    @LlamAcademy

    5 ай бұрын

    💪

  • @Subrata157
    @Subrata157 Жыл бұрын

    ❤❤❤❤❤Plz make a 3rd person weapon pick up and switch ❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    This is on the plan for the series because it seems to be a popular request. Initially I did not plan for it because it's kind of a "related topic" but not necessarily directly part of the gun system. Maybe around part 10 or so we may hit that topic. Not sure exactly the number yet 🤔

  • @juanmagarciamarin5694
    @juanmagarciamarin56942 ай бұрын

    Yor GitHub code of ShootConfigScriptableObject give me errors :(

  • @LlamAcademy

    @LlamAcademy

    2 ай бұрын

    Can you open an issue on GitHub with the errors you are getting?

  • @juanmagarciamarin5694

    @juanmagarciamarin5694

    2 ай бұрын

    @@LlamAcademyDon't worry I fixed it, thank u

  • @mystocity
    @mystocity8 ай бұрын

    can't find surfacemanager

  • @LlamAcademy

    @LlamAcademy

    8 ай бұрын

    Check the pinned comment and description

  • @mystocity

    @mystocity

    8 ай бұрын

    I'm sorry but I'm kind of confused I don't know what i'm looking for in the description@@LlamAcademy

  • @LlamAcademy

    @LlamAcademy

    8 ай бұрын

    @mystocity In this video I DO NOT cover the Impact System: kzread.info/dash/bejne/nYhmvNqjfdi6j5c.html you can check out that video for the full explanation for how that works That’s for the SurfaceManager and ImpactType both. If you’re not interested in using that system for impacts, feel free to just remove that code! Everything will still work! PlayerIK is a very simple demo script implemented solely for the demo. As I mention in the video, this will be covered in the future, so you can skip that part for now, or check out the project on GitHub to see that naïve implementation.

  • @mystocity

    @mystocity

    8 ай бұрын

    oh thanks for the help idk why I was so stupid@@LlamAcademy

  • @andrewallbright658
    @andrewallbright658 Жыл бұрын

    Pew pew pew pew pew pew! Manager singletons are one of the more difficult things I've yet to wrap my head around. Oh, it's not because I don't understand... I just don't know when you would want something (1) where you guarantee in code that only one thing exists (2) where it must be globally accessible to all scripts (3) where it groups together a bunch of things and provides an API to "manage" (whatever that means) the bunch of things. Some people even add "don't destroy on scene load" type logic so that the manager singleton lives across multiple scenes. I don't really understand why they're so ubiquitous by game dev pedagogy. At first I thought "oh, it's simple and you can avoid thinking about dependency injection!" Now, for me, if I need something like a manager singleton I just only put one of the thing in the scene (designer guarantee) and use FindObectOfType() on start which I argue is much simpler than a manager singleton. Which begs the question...

  • @andrewallbright658

    @andrewallbright658

    Жыл бұрын

    I have a feeling going heavy into manager singletons is probably a style of game programming. I think maybe a competing style is an event driven style. I feel like I'm grasping at mist with this explanation but it directionally feel right. It's like how you can make a web server in OOP paradigm or a functional paradigm; from the users perspective it's exactly the same even though the code constructs and abstraction is waaaay different between the two paradigms. Maybe. Maybe... Or it's just that Unity pedagogy doesn't want to get into the intricacies of monobehaviours, scenes, scriptable objects, assets, etc before showing someone who to shoot an orc in the face.

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    It took me a minute to realize you were talking about the SurfaceManager, sorry. They're ubiquitous in gamedev because they solve a problem that is frequently needed in a simple way to implement, understand, and debug. You could do the same "SurfaceManager" with some kind of event bus handle these via events but sometimes those are more difficult to debug. But you still have a static, globally accessible class everything has to know about 🙂. Sure the EventBus makes it so you only need 1 EventBus and it can handle ALL events, but from your first post, this is the same concept of having a single, static, global, enforced in code class. Regarding using FindObjectOfType. I actually did exactly that in my first game. It adds significant first-frame stutter when loading into the game if you have complex scenes or many objects needing to find that singleton because FindObjectOfType iterates over every object (then every component on each object) in the scene until it's found, then it has to do that for each script that needs to FindObjectOfType before the first frame is rendered. The singleton class can fully eliminate that startup cost by having the instance reference already there in the static variable. Singleton's aren't always good and can easily be abused, but I wouldn't say they have no place in programming, gamedev or otherwise.

  • @andrewallbright658

    @andrewallbright658

    Жыл бұрын

    ​@@LlamAcademy Thanks for sharing some of how you think about managers/singletons. I still struggle to find a great place for them and I'm actually trying. I'm not just a contrarian for contrarian's sake and I'm making honest attempts :) I think perhaps a dynamic at play with me is that I'm a little bias against anything static due to leaning hard into testing? Special care is required when handling a singleton to ensure one test doesn't interfere with another. Its so much easier to leave statics in the tool box unless the value it offers outweighs the hassle in tests. There are certainly ways to hard reset a singleton before each test. Having watched quite a few game dev tuts I noticed how ubiquitous they are. I see that as a sign that there's something I'm not "getting" with the technique. I will say that one thing singletons do extremely well is to sidestep complicated dependency injection concerns.

  • @ghostzone985
    @ghostzone9857 ай бұрын

    Are you sure that everything has been commited o github? I am facing NullReferenceException on GunScriptableObject.cs:294 and PlayerAction.cs:46 right away. It seems that ShootSystem is missing

  • @LlamAcademy

    @LlamAcademy

    7 ай бұрын

    Looks like you didn’t import Unity Particle Pack. Make sure you review the setup instructions in the readme!

  • @nightyonetwothree
    @nightyonetwothree Жыл бұрын

    shooting logic inside scriptable object ... damn smells bad

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    Can you help me understand your point of view for why a ScriptableObject should not have logic within it?

  • @TW-ox9uv
    @TW-ox9uv8 ай бұрын

    unity is dead rip

  • @1mag1n33dev
    @1mag1n33dev Жыл бұрын

    i'm getting this error in my code in the PlayerGunSelector.cs Severity Code Description Project File Line Suppression State Error CS0246 The type or namespace name 'PlayerIK' could not be found (are you missing a using directive or an assembly reference?) Assembly-CSharp \Unity projects\package creation project\Assets\Guns\Scripts\PlayerGunSelector.cs 13 Active

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    Hi 👋 You can skip over anything to do with PlayerIK, or you can pull the script off the GitHub repository: github.com/llamacademy/scriptable-object-based-guns/tree/part-1 I mentioned several times in here a better IK will be covered in a future video in this series. This script is pretty basic to just make the demo look okay

  • @psychoknight9208
    @psychoknight92085 ай бұрын

    I was following along and writing out the code and after applying all the script to the objects I try to debug and I get this error All the other code through trial and error now works, but this one I cant figure out NullReferenceException: Object reference not set to an instance of an object GunScriptableObject.Shoot () (at Assets/Scripts/WeaponSystem/GunScriptableObject.cs:42) PlayerAction.Update () (at Assets/Scripts/WeaponSystem/PlayerAction.cs:15) Line 42 on GunScriptableObject references ShootSystem.Play(); for playeraction.cs Im using the Input.GetMouseButton(0) as the Mouse.current.leftButton.isPressed gives me an error for Mouse not existing.

  • @LlamAcademy

    @LlamAcademy

    5 ай бұрын

    Hi! For the first issue, you should have a Particle System as a child of your gun model that is positioned at the tip of the gun for the muzzle flash. If you do not have this you will get that error. For the second error you need to be using the “new” input system. The “old” input system does not have the “Mouse” class. This can be changed in the Project Settings > Player > Other > Configuration > Active Input Handling

  • @psychoknight9208

    @psychoknight9208

    5 ай бұрын

    @@LlamAcademy This fixed the 2 issues, but now the gun exclusively fires on the x axis at a 45 degree angle (fires left with trails going left from the starting position of the gun no matter where the gun is pointed. I have tried adjusting a few things but cant find the culprit) I have for now moved onto an advanced movement script as the when placing creating the gun to adjust its position based on camera rotation was for some reason causing my char controller to bug out and not move at all.

  • @RandomSZ
    @RandomSZ Жыл бұрын

    i have gotten everything down though i got this error message: NullReferenceException: Object reference not set to an instance of an object GunScriptableObject.Shoot () (at Assets/Scripts/Weapons/Guns/GunScriptableObject.cs:44) PlayerAction.Update () (at Assets/Scripts/Weapons/Guns/PlayerAction.cs:16) and not sure what the issue is

  • @RandomSZ

    @RandomSZ

    Жыл бұрын

    it seems to be the .Shoot(); and .Play(); arent working

  • @LlamAcademy

    @LlamAcademy

    Жыл бұрын

    Based on the limited information here, I can only guess that maybe your gun does not have a particle system assigned as a child at the barrel of that gun.

  • @RandomSZ

    @RandomSZ

    Жыл бұрын

    how i assign my particle system onto the gun as a child?

  • @RandomSZ

    @RandomSZ

    Жыл бұрын

    @@LlamAcademy nevermind i figured out how to assign the particle system and yes this was the issue thank you so much, i forgot to actually add my own particle system onto the gun and thought the bullet and its particle system would implement onto the gun somehow but turns out it was not the case. but again thank you i am so far loving this tutorial series and your tutorials are very noob friendly which is very awesome so thanks you for this amazing content, keep up the good work im sure you'll come very far! :)

  • @sabinekine2737
    @sabinekine27378 ай бұрын

    Are these tutorials outdated/redundant? I'm using Unity 2022.2.14 and I'm getting errors that stop me from progressing, though I can't find anyone else with the same errors in the comments so it could be on my end. I've tried to compare my code to your git, but even going all the way back to the first merge pull request in November 1st 2022, this code is just missing? So I can't compare. It'd be useful to have a git for each tutorial for comparing code as I go along, because just trying to compare to the 'finished product' 13 tutorials in is messy. { ActiveMonoBehaviour.StartCoroutine( PlayTrail( ShootSystem.transform.position, hit.point, hit // error CS1503: ARGUMENT 3: CANNOT CONVERT FROM 'UNITYENGINE.RAYCASTHIT' TO 'UNITYENGINE.RAYCASTCOMMAND' ) ); } else { ActiveMonoBehaviour.StartCoroutine( PlayTrail( ShootSystem.transform.position, ShootSystem.transform.position + (shootDirection * TrailConfig.MissDistance), new RaycastHit() // CS1503: error ARGUMENT 3: CANNOT CONVERT FROM 'UNITYENGINE.RAYCASTHIT' TO 'UNITYENGINE.RAYCASTCOMMAND' ) ); } I've triple checked the code but I can't find any mistakes in my GunScriptableObject script. My scriptable objects also aren't showing up in Unity despite being copied from your own code, I only have Guns/ShootConfiguration - maybe because this script is order 0 and is broken.

  • @LlamAcademy

    @LlamAcademy

    8 ай бұрын

    There is a branch for each tutorial. You can find them on GitHub as “part-X” branch. Based on the error it sounds like you have defined “hit” as a RaycastCommand instead of RaycastHit

  • @sabinekine2737

    @sabinekine2737

    8 ай бұрын

    @@LlamAcademy Oh great, I'm new to Git so I didn't see the branch setup, this'll be great for cross-referencing! And, of course, there was that elusive error in my IEnumerator PlayTrail code. Thank you for the help!

  • @LlamAcademy

    @LlamAcademy

    8 ай бұрын

    I’m glad you got it working! Have fun!