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.
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.
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
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.
hi first this is a very good tutorial in the content aspect but its really hard to understand because youre talking both to fast with not enough detail and in monotone making it hard to understand and really boring
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
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!!!
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);
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
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.
For some reason the Game Object even when I have these in and have no errors Target.cs using System.Collections; using System.Collections.Generic; using UnityEngine; public class Target : MonoBehaviour, IDamageable { private float health = 100f; public void Damage(float damage) { health -= damage; if (health
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
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.
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?
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
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!
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
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.
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
Not neccesarily, Personaly i would cast a ray from the forward direction of the camera to have consistancy between all weapons and where they aim. This way, you also have more freedom to position the weapon how you want so it looks better in the camera view
Yea as @C4uTi0N said it won't hit the centre of the screen. Depending on the position of the gun it'll be slightly offset. If you would like it to be exactly the centre you can use the camera's position as the origin and the camera's forward as the direction of the Ray.
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???
it is showing me this error Assets\Scripts\Gun.cs(50,77): error CS0246: The type or namespace name 'IDamageable' could not be found (are you missing a using directive or an assembly reference?) Pls help!
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?
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
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. 😞
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);
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.
When the world needed him the most, he came back
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.
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.
Great video can't wait for the following videos about the effects
Thanks for coming back
Amazing !! this was like a whole fps tutorial
thank you so much plai these are the tutorials we need, nice keyboard sound by the way i like it
Man, thats a extremely good tutorial. Thank you very much. Maximum useful information in minumum time.
well well well, look who remembered his login.
good to have you back plai
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
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
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.
hi first this is a very good tutorial in the content aspect but its really hard to understand because youre talking both to fast with not enough detail and in monotone making it hard to understand and really boring
short and to the point as a dev should be good job best tutorials on yt
New video!!!
Hype
Hey man! Great tutorial! Could make a follow up video showing us how to add animations to the gun?
can U make a video on crouching and sliding on ur character movement scripts.
Amazing videos, you probably know how hard it was to start game developing and right now that is me, thank you for helping. 🤗
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
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.
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?
Dude you are the only guy that actually deserves all sub, like and alarm buttons, truly worthy contents.
There is something strange in the WeaponSway script, it turns my weapon 180 degrees facing me. please help
i got everything else working but the shooting it doesn't work for me
same
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);
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
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.
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...
"type or namespace name 'IDamageable' could not be found" tf do i do here
🧿
Awesome tutorial
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.
Plai is Back
For some reason the Game Object even when I have these in and have no errors
Target.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Target : MonoBehaviour, IDamageable
{
private float health = 100f;
public void Damage(float damage)
{
health -= damage;
if (health
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
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.
btw weapon sway
using System;
using UnityEngine;
public class WeaponSway : MonoBehaviour
{
[Header( "Sway settings")]
[SerializeField] private float smooth;
[SerializeField] private float multiplier;
private void Update()
{
float mouseX = Input.GetAxisRaw("Mouse X") * multiplier;
float mouseY = Input.GetAxisRaw("Mouse Y") * multiplier;
Quaternion rotationX = Quaternion.AngleAxis(-mouseY, Vector3.right);
Quaternion rotationY = Quaternion.AngleAxis(mouseX, Vector3.up);
Quaternion targetRotation = rotationX * rotationY;
transform.localRotation = Quaternion.Slerp(transform.localRotation, targetRotation, smooth * Time.deltaTime);
}
}
How do I set the reload key by default to be R?
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?
Waste of time so bad
I'm getting an error saying Target.cs(5,14), error CS0101, global namespace already contains a defintion for 'Target'
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
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!
I like how you actually tell us what we're scripting instead of just showing us what to write down
how would you do the shooting button for a ps4 controller right trigger
thanks!
ay new vid very nice and helpfull
How can i learn code, i want be good just like you
multi-player fps parkour. or don't you probably don't know how to 😂
he's not dani you can't tempt him like that
I realized I accidentally wrote `TakeDamage` instead of `Damage` at the end there. Sorry about that.
bruh
I keep getting an error saying the type namespace name ‘action’ could not be found
if you look at the top of your script there's a bunch of lines says using etc under using unityengine put this:
using System;
@@melamri6640 ok
@@melamri6640 Thanks for this
ive been trying for 2 hours to find out what and how to use pivot mode is
for me it says The modifier 'private' is not valid for this item for the private void update is there anyway to fix this?
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
I've followed every step but my gun still ain't reloading
Yay its Plai
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
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.
Will you remember me when you are famous?
maybe
I have a question , what version of unity will this work on?.
Sprint and crouch system please!
using System;
using UnityEngine;
public class WeaponSway : Monobehaviour {
[header("Sway Settings:)]
[SerializeField] private float smooth;
[SerializeField] private float multiplier;
private void Update()
{
// get mouse input
float mouseX = Input.GetAxisRaw("Mouse X") * multiplier
float mouseY = Input.GetAxisRaw("Mouse Y") * multiplier
// calculate target rotation
quaternion rotationX = Quaternion.angleAxis(-mouseY, Vector3.right);
Quaternion rotationY = Quaternion.AngleAxis(mousex, vector3.up);
quaternion targetRotation = rotationX * rotationY;
//rotate
transform.localRotation = quaternion.slerp(transform.localrotation, targetRotation, smooth * Time.deltaTime);
}
)
script :D
PEW PEW PEW
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
Thank you so much bro, can you do about melee or combat system
does the raycast always hit anything that is on the middle of the screen (crosshair) even if it is on the muzzle which is offset from the middle
Not neccesarily, Personaly i would cast a ray from the forward direction of the camera to have consistancy between all weapons and where they aim.
This way, you also have more freedom to position the weapon how you want so it looks better in the camera view
Yea as @C4uTi0N said it won't hit the centre of the screen. Depending on the position of the gun it'll be slightly offset. If you would like it to be exactly the centre you can use the camera's position as the origin and the camera's forward as the direction of the Ray.
Ok Thx
May GOD Bless you ❤
How do I get the weapon sway code to work with an animator?
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
I have a error in Gundata what do I do
i cant get it to work helpppppppp
What is the font you use in your intro and other text?
If only I had unity
can anyone explain why my gun doesnt move in directions, theres no error in the console, it just doesnt move with my mouse
nv fixed it
I can't do the shoot cause the Action variable is not working
same
it is showing me this error Assets\Scripts\Gun.cs(50,77): error CS0246: The type or namespace name 'IDamageable' could not be found (are you missing a using directive or an assembly reference?) Pls help!
I have the same issue tell me if you solve it
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
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?
i get an error on the last line of code for 'TakeDamage' plz some one help it says theres no reference to it
@Dev I fixed It a long time ago
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
Thank :)
how do you add sounds
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?
I understand everything on first try ,that is just brilliant man
plai when are you gonna make your own game?
I ask myself the same question 😩
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?
Your the best,Thanksss
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);
Yesss he comes back!
Helpful
bro im so glad your making videos, there so good haha
it wont shoot
YOO PLAI NEW VID LESS GOO
error CS0246: The type or namespace name 'IDamageable' could not be found (are you missing a using directive or an assembly reference?
The game is telling me that the modifier 'public' on the IDamageable script is not valid for the item, can anyone help?
ty so much
HOW DO U ENTER PIVOT MODE
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.
when i write the playershoot unity gives an error for action plz help
same for me
You have to put "using System;" at the top of the script. its there in his video, but never called out so its easy to miss
can you slow down pls your saying stuff i never heard of in my life like they're obvious
the "TakeDamage" thing is causing an Error, it is not variable or declared
did you find a fix?
ohh i just found another comment that says this "take the Damage function and just change its name to TakeDamage
". it works!!! (hope it helps) :)