If anyone has the issue of their weapon facing their camera parallel after trying to implement weapon sway, you're issue may be that when you switched your gun 180 when positioning it, you may have put your sway script in the same directory. For Example, if you changed the direction of your gun in your weapon holder section, and also put the sway script in that same area, and are having this issue, correct the direction of the gun in its folder instead of weapon holder folder. Hope this helped anyone who needed it, and sorry if it's kinda confusing I'm not great at explaining things.
Damn this is very convenient i was just about to continue my 3D project after trying out 2D thank you very much! Hey plai can you make a tutorial about melee weapons next like sword swing, throw damage etc.
Nice video actually showing you a more modular weapon system rather than just showing you how to do a raycast and that's it, like most other tutorials. My spaghetti code thanks you
7:01 to avoid this, delete the variable currentAmmo from the GunData script and instead put a variable inside Gun named localAmmo. In Start() just assign localAmmo to be equal to gunData.magSize. Replace gunData.currentAmmo with localAmmo where needed.
how convinient, I opened unity for the first time in a while yesterday to try and recreate an old game that was supposed to have weapons (wasn't smart enough back then) I'm still gonna use my terrible system but probably do something similar to your damage interface
hey this vid great and i love it but if anyone got any errors that say something like muzzle variable or muzzle not assigned just go to your gun's inspector then where it says transform select your muzzle then no error
Thanks for the nice tutorial! Just a quick question here! I'm wondering what's the main difference of making "gun script" with every variable in the "gun data script" and attach it to each weapon and change the parameter, versus doing exactly what you did in the video where you make "gun data" a scriptable object and use those variables in the "gun script"? I'm interested in mastering OOP and Scriptable Object more so I'd love to learn the advantage of doing the latter method!
Great! It was not ok for me to use a Raycast, 1-st because of my gun in the center of the screen (so it was always a "target" for cameras), and 2-nd I wanted a physical bullet, but not a "virtual" one. So I mixed your code with some other simple features, worked perfect!!!
hey bro great tutorial but can u please help me its says The type or namespace name "Action " could not be found (edit) im so dumb unity hating on me not putting "using System;" up at the top but i fixed it no issues
I am getting two errors, one says "error CS0106: The modifier 'public' is not valid for this item" and the other says "error CS0535: 'Target' does not implement interface member 'IDamageable.Damage(float)' I also get an error when I try to add the target script to the target object, that reads "Can't add script component 'Target' because the script class cannot be found. Make sure that there are no compile errors and that the file name and class name match." Please help, I've been trying to fix this for ages to no avail. The 'public' in "public void damage(float damage);" inside IDamageable is uncolored in visual studio so that seems to be part of why it's not working.
If you have the error "cs0106 " The modifier 'public' is not valid for this item , simply delete the public should keep this = void TakeDamage(float damage);
this tutorial is great but i cant figure out how to make semi automatic weapons how do I reference the gundata scriptable object in the player shoot script to check if a weapon is automatic or not so that if it is semi automatic it only shoots when the mouse is pressed once
Can you please make a video explaining all these things in more detail? Because just copying and pasting doesn't help much. It might help a little bit, but learning what these things do (at least the things I don't understand) is more efficient.
on the script gun I got error CS0103 the type or namespace name "Damageable" could not be found twice at 15,9 and 16,9 and then it says. the name 'Playershoot' does not exist in current context what do I do. I'm using notepad by the way.
Idk if ive done something but i completed the tutorial worked all fine and my gun could shoot and reload, then randomly it stopped shooting and i cant find a way to fix?
hey gus i've just started a game project and in 4:42 i don't understand anything and unity gives me an error : Playershoot does not contain a definition for shootinput
So why would using Scriptable Objects like this be better than creating a gun base class that has all of the universal stats, then inheriting from that in the individual gun scripts. And you can set the stats for the guns individually in the inspector if they are public in the base class
A realy great Video Plai ! But i stuck :_( I get the error message " Target' does not implement interface member 'IDamageable.Damage()' " and i dont get the red lines in the visual studio to folow your steps. 😞
Hello! At the start of the video when you add the sway, mine worked, but also did not work. What happened was the sway is there but it turned my gun sideways??? How can you help???
At 10:28 you type damagable?.TakeDamage(gunData.damage); but there is no reference for TakeDamage in IDamageable. I'm pretty sure you just meant the void "Damage" you created at 10:08 because I used it instead and it worked. Feel free to correct me.
Can someone help me? im having a issue with the code. im getting this error: "Assets/Scripts/IDamageable.cs(8,17: errorCS0106: the modifier 'public' is not valid for this item" I have no idea what it means
Says that error CS0246: The type or namespace name 'RangedWeapons' could not be found (are you missing a using directive or an assembly reference?) (I renamed it to ranged weapons cause imma add melee weapons after) even though its right there! thanks for taking your time if you'd like to help.
i need help, when i put thre muzzle stuff in i got this error message: "Assets\scripts\Gun.cs(28,39): error CS1061: 'RaycastHit' does not contain a definition for 'muzzle' and no accessible extension method 'muzzle' accepting a first argument of type 'RaycastHit' could be found (are you missing a using directive or an assembly reference?)" is there any way to fix this?
It says that you are missing a reference. If you press ALT + ENTER while having the cursor on the code that gives the error, it should help you to fix it
getting this error. Assets\scripts\Gun.cs(54,32): error CS1061: 'IDamageable' does not contain a definition for 'TakeDamage' and no accessible extension method 'TakeDamage' accepting a first argument of type 'IDamageable' could be found (are you missing a using directive or an assembly reference?)
To fix the error, you should add the TakeDamage method to the IDamageable interface. For example: java Copy code public interface IDamageable { void TakeDamage(float damageAmount); } It worked for me :D
in the playershoot script im getting this error: Assets\PlayerShoot.cs(8,19): error CS0246: The type or namespace name 'Action' could not be found (are you missing a using directive or an assembly reference?)
Does somebody know why when i write the [CreateAssetMenu part it gives me CS1012 which is too many charecters in literal and i try the softwares fixes which didnt work so does anybody know a fix?
once i complete the final step of the tutorial and save my code, it says that "TakeDamage" is not something it identifies it, was there somewhere I was supposed to reference it
When making the PlayerShoot script, Microsoft Visual Studio gave me an error saying that "Action" i not a valid name for a public static field? did I miss something?
When the world needed him the most, he came back
It's therapy for me to watch you code these scripts. It's an art form. Thank you very much for the content. It was better than what I expected.
well well well, look who remembered his login.
good to have you back plai
I like how you actually tell us what we're scripting instead of just showing us what to write down
If anyone has the issue of their weapon facing their camera parallel after trying to implement weapon sway, you're issue may be that when you switched your gun 180 when positioning it, you may have put your sway script in the same directory. For Example, if you changed the direction of your gun in your weapon holder section, and also put the sway script in that same area, and are having this issue, correct the direction of the gun in its folder instead of weapon holder folder.
Hope this helped anyone who needed it, and sorry if it's kinda confusing I'm not great at explaining things.
Dude you are the only guy that actually deserves all sub, like and alarm buttons, truly worthy contents.
nice and fast, to the point, no unneccasary explaining. perfect! wish every tutorial was like this.
edit: suggestion maybe an interaction system
not hard to code, legit just takes some simple triggers and input detection
@@gerblesh_674 you are on a tutorial...
Damn this is very convenient i was just about to continue my 3D project after trying out 2D thank you very much!
Hey plai can you make a tutorial about melee weapons next like sword swing, throw damage etc.
Just use a short raycast and possibly a delay at the start to compensate for swingtime
@@abel099 that's genius
@@saulgoodman5662 Thanks but that's just how most games do it.
Great video can't wait for the following videos about the effects
Amazing videos, you probably know how hard it was to start game developing and right now that is me, thank you for helping. 🤗
Thanks for coming back
Amazing !! this was like a whole fps tutorial
Thanks for this, its been really fun making shotguns, assault rifles and pistols using this script, youre a really big help to the indie devs.
Nice video actually showing you a more modular weapon system rather than just showing you how to do a raycast and that's it, like most other tutorials. My spaghetti code thanks you
Thank you. None of the shooting tutorials cover how to prevent spamming by clicking and attacking constantly.
Man, thats a extremely good tutorial. Thank you very much. Maximum useful information in minumum time.
I understand everything on first try ,that is just brilliant man
thank you so much plai these are the tutorials we need, nice keyboard sound by the way i like it
bro im so glad your making videos, there so good haha
7:01 to avoid this, delete the variable currentAmmo from the GunData script and instead put a variable inside Gun named localAmmo.
In Start() just assign localAmmo to be equal to gunData.magSize.
Replace gunData.currentAmmo with localAmmo where needed.
Thx you are my hero
how convinient, I opened unity for the first time in a while yesterday to try and recreate an old game that was supposed to have weapons (wasn't smart enough back then)
I'm still gonna use my terrible system but probably do something similar to your damage interface
hey this vid great and i love it but if anyone got any errors that say something like muzzle variable or muzzle not assigned just go to your gun's inspector then where it says transform select your muzzle then no error
Thanks for the nice tutorial! Just a quick question here!
I'm wondering what's the main difference of making "gun script" with every variable in the "gun data script" and attach it to each weapon and change the parameter, versus doing exactly what you did in the video where you make "gun data" a scriptable object and use those variables in the "gun script"? I'm interested in mastering OOP and Scriptable Object more so I'd love to learn the advantage of doing the latter method!
thank you, this is a well optimized code for any gun imo
Thank you so much, you explain things quickly and don't take 20 minutes to create a basic weapon system +1 sub
Yesss he comes back!
4:34 we should also subscribe to this channel.
Good tutorial
Hey man! Great tutorial! Could make a follow up video showing us how to add animations to the gun?
I realized I accidentally wrote `TakeDamage` instead of `Damage` at the end there. Sorry about that.
bruh
Thats why I got a error
Great! It was not ok for me to use a Raycast, 1-st because of my gun in the center of the screen (so it was always a "target" for cameras), and 2-nd I wanted a physical bullet, but not a "virtual" one. So I mixed your code with some other simple features, worked perfect!!!
what other features for the visual bullet?
hey bro great tutorial but can u please help me its says The type or namespace name "Action " could not be found
(edit) im so dumb unity hating on me not putting "using System;" up at the top but i fixed it no issues
New video!!!
Hype
I am getting two errors, one says "error CS0106: The modifier 'public' is not valid for this item" and the other says "error CS0535: 'Target' does not implement interface member 'IDamageable.Damage(float)'
I also get an error when I try to add the target script to the target object, that reads "Can't add script component 'Target' because the script class cannot be found. Make sure that there are no compile errors and that the file name and class name match."
Please help, I've been trying to fix this for ages to no avail. The 'public' in "public void damage(float damage);" inside IDamageable is uncolored in visual studio so that seems to be part of why it's not working.
If you have the error "cs0106 " The modifier 'public' is not valid for this item ,
simply delete the public should keep this =
void TakeDamage(float damage);
9:11 - lmao, this totally caught me off guard!
this tutorial is great but i cant figure out how to make semi automatic weapons how do I reference the gundata scriptable object in the player shoot script to check if a weapon is automatic or not so that if it is semi automatic it only shoots when the mouse is pressed once
short and to the point as a dev should be good job best tutorials on yt
Can you please make a video explaining all these things in more detail? Because just copying and pasting doesn't help much. It might help a little bit, but learning what these things do (at least the things I don't understand) is more efficient.
Really cool video continue !! :3
thanks :)
@@plaidev ;3
There is something strange in the WeaponSway script, it turns my weapon 180 degrees facing me. please help
Ayee thanks so much for this bro, it's super useful
Killed it buddy
i was checking for every gun active in hierarchy and then adding everything gun wise😅
on the script gun I got error CS0103 the type or namespace name "Damageable" could not be found twice at 15,9 and 16,9 and then it says. the name 'Playershoot'
does not exist in current context what do I do.
I'm using notepad by the way.
How tf is this only 749 likes, this def deserves more
YOO PLAI NEW VID LESS GOO
YOOOOOOOO I’ve been watching you this week
Lets go, new video!
You're back, on my birthday :)
Happy birthday!
Lets go another pogger tutorial 🤩
Great Vid but can you help me with something, when i do this - [SerializeField] GunData gunData; it doesnt show me the section to put gun data
you are the best teacher in the world
I'm getting an error saying Target.cs(5,14), error CS0101, global namespace already contains a defintion for 'Target'
Thank you I needed this 🙏
thanks!
Sick Tutorial bro.
Great tutorial!
Everyone...
HE'S BACK!!
I have a problem where Target does not implement member IDamageable.Damage()’
ive been trying for 2 hours to find out what and how to use pivot mode is
can U make a video on crouching and sliding on ur character movement scripts.
Plai is Back
I'll need this in 2 years
Welcome back
Help!! When I get collide with wall or anyother object, the raycast goes through and draw the line and won't damage the enemies, how can I fix it?
Plai is back 😳
how would you do the shooting button for a ps4 controller right trigger
I have a question , what version of unity will this work on?.
Your the best,Thanksss
babe wake up plai made a new video
Idk if ive done something but i completed the tutorial worked all fine and my gun could shoot and reload, then randomly it stopped shooting and i cant find a way to fix?
for me it says The modifier 'private' is not valid for this item for the private void update is there anyway to fix this?
🧿
Awesome tutorial
"type or namespace name 'IDamageable' could not be found" tf do i do here
less gooo you're back _DDDDDDDDD
error CS0246: The type or namespace name 'IDamageable' could not be found (are you missing a using directive or an assembly reference?
What is the font you use in your intro and other text?
i got everything else working but the shooting it doesn't work for me
same
hey gus i've just started a game project and in 4:42 i don't understand anything and unity gives me an error : Playershoot does not contain a definition for shootinput
me too bro
So why would using Scriptable Objects like this be better than creating a gun base class that has all of the universal stats, then inheriting from that in the individual gun scripts. And you can set the stats for the guns individually in the inspector if they are public in the base class
A realy great Video Plai ! But i stuck :_( I get the error message " Target' does not implement interface member 'IDamageable.Damage()' " and i dont get the red lines in the visual studio to folow your steps. 😞
did u figure out the problem?
Hello! At the start of the video when you add the sway, mine worked, but also did not work. What happened was the sway is there but it turned my gun sideways??? How can you help???
There is line with float MouseX
In MouseX after the swayMultiplier change it to -360f (idk you need to test)
Also in Quaternion rotation X change last few words to (mouseY, Vector3.left
At 10:28 you type damagable?.TakeDamage(gunData.damage); but there is no reference for TakeDamage in IDamageable.
I'm pretty sure you just meant the void "Damage" you created at 10:08 because I used it instead and it worked.
Feel free to correct me.
Can someone help me? im having a issue with the code. im getting this error: "Assets/Scripts/IDamageable.cs(8,17: errorCS0106: the modifier 'public' is not valid for this item"
I have no idea what it means
Says that error CS0246: The type or namespace name 'RangedWeapons' could not be found (are you missing a using directive or an assembly reference?)
(I renamed it to ranged weapons cause imma add melee weapons after)
even though its right there! thanks for taking your time if you'd like to help.
what is the extension that you are using in your visual studio for code ?
yooooo plai is back
i need help, when i put thre muzzle stuff in i got this error message: "Assets\scripts\Gun.cs(28,39): error CS1061: 'RaycastHit' does not contain a definition for 'muzzle' and no accessible extension method 'muzzle' accepting a first argument of type 'RaycastHit' could be found (are you missing a using directive or an assembly reference?)" is there any way to fix this?
It says that you are missing a reference. If you press ALT + ENTER while having the cursor on the code that gives the error, it should help you to fix it
How do I set the reload key by default to be R?
getting this error. Assets\scripts\Gun.cs(54,32): error CS1061: 'IDamageable' does not contain a definition for 'TakeDamage' and no accessible extension method 'TakeDamage' accepting a first argument of type 'IDamageable' could be found (are you missing a using directive or an assembly reference?)
Same error 😢did you fix it?
@Archy_ I have the same did you end up working it out?
Problem*
@@grizzlydonnutt Yes, I have. Just change the ‘IDamageable’ from the damageable?.’IDamagebale’ to ‘Damage’ and it will be ok.
To fix the error, you should add the TakeDamage method to the IDamageable interface. For example:
java
Copy code
public interface IDamageable
{
void TakeDamage(float damageAmount);
}
It worked for me :D
I've followed every step but my gun still ain't reloading
in the playershoot script im getting this error:
Assets\PlayerShoot.cs(8,19): error CS0246: The type or namespace name 'Action' could not be found (are you missing a using directive or an assembly reference?)
Please show your code, because I had the same issue but cant remember how I solved it
@@fireburst6868 i already solved it i just asked chat gpt
@@fireburst6868 just add "using system;" at the start of your code, he forgot to include it.
Does somebody know why when i write the [CreateAssetMenu part it gives me CS1012 which is too many charecters in literal and i try the softwares fixes which didnt work so does anybody know a fix?
YOOO LETS GO ANOTHER UPLOAD YOURE SICK
once i complete the final step of the tutorial and save my code, it says that "TakeDamage" is not something it identifies it, was there somewhere I was supposed to reference it
change "TakeDamage" to just "Damage"
@@westron7257 That didn't work for me
Can anyone pls help? When I drag the Scriptable object into Gun data field, it shows that it should be the same class name.
By the way nice video!
Thanks! Maybe the name of the file and the name of the class are different? They should be the same.
Yay its Plai
YEEEEEEEEEEEEEEEEEEEEES YOU CAME BAAAAAAAAAAAAAAAAACK
How do I get the weapon sway code to work with an animator?
When making the PlayerShoot script, Microsoft Visual Studio gave me an error saying that "Action" i not a valid name for a public static field?
did I miss something?
just say "using System" at the beggining (worked for me)
The game is telling me that the modifier 'public' on the IDamageable script is not valid for the item, can anyone help?
The goat 🐐
yooo