Timestamp: ~2:25. Hey, I chose to use the "Damage Gun" version, and I'm getting an error that says: error CS0246: The type or namespace name 'Entity' could not be found (are you missing a directive or an assembly reference?).
using System.Collections.Generic; using UnityEngine; public class Entity : MonoBehaviour { [SerializeField] private float StartingHealth; private float health; public float Health { get { return health; } set { health = value; Debug.Log(health); if (health
tried this, didint work- tried joining the discord to see the code- didint work.. it just says theres an object refrence not set to an instance of an object.. NVM! Set your camera to maincamera in its tags, that should do the trick!
Another Dude that thinks he can code but just wastes peoples time, there is not health reference code full of errors, if you need a tutorial look for someone more knowledgeable. SKIP this GUY
using System.Collections.Generic; using UnityEngine; public class DamageGun : MonoBehaviour { public float Damage; public float BulletRange; private Transform PlayerCamera; private void Start() { PlayerCamera = Camera.main.transform; } public void Shoot() { Ray gunRay = new Ray(PlayerCamera.position, PlayerCamera.forward); if (Physics.Raycast(gunRay, out RaycastHit hitInfo, BulletRange)) { if (hitInfo.collider.gameObject.TryGetComponent(out Entity enemy)) { enemy.Health -= Damage; } } } } damage gun
Code is in the discord for those who need it! (Link in the description)
I can't find the code
@@MonkeMan71 go to #code-archives in the discord after getting the rewction role
@@Rytech_Devthanks
@@Rytech_Dev I cant found the role #code-archives 😥
@@abirzebiri4347 its channel in category main channels
YOU ARE A LEGEND!!! THANK YOU SO MUCH!! ive been trying to learn how raycasts work and this is so simple and easy to follow. Very underrated!!
this is an amazing tutorial, it gives you a customizable and very mobile system in such a short time, thanks
Wonderful tutorial, I enjoyed that you took a second to explain each step.
I'll tell ya what, this is a really solid video. Good job mate
I don't think I deserve this Tutorial, So much info in so little time!
I never knew about a Unity Event :/ thanks man i can do alot that just guns with this new info bro.
anyone know why there wouldnt be a shoot() function under the damage gun tab on the event handler, as shown at 2:50?
I did that wrong
Go to the Damage Gun script and make it to public instead of private in the shoot function
You are a gentlemen and a scholar
UR A LIFE SAVER THANK YOU SO MUCH!!!
hey just wondering how could u add muzzle flash and damage indicators when shooting enemies?
So Helpful! ❤
Please make a video how to add particles to it
using unity particle sistem a great sistem (watch dani if you know what i mean)
Cool tutorial, if you could add some chill music maybe. That would be nice in your future videos ^^
this is very clever, I am using this method in godot!
hey there, where can we download the code for copy and paste? i have some errors and dont wanna debug them all
From his discord server. But it actually have a bit of errors, so stay attentive!
Really good.
Timestamp: ~2:25. Hey, I chose to use the "Damage Gun" version, and I'm getting an error that says: error CS0246: The type or namespace name 'Entity' could not be found (are you missing a directive or an assembly reference?).
nvm i figured it out :P
@@lasernugg How?
alright, all you need to do, is create a new script, and name it as "Entity". And just copy the code from the video
@@whysl I’m pretty sure you just do both gun versions, that fixed it for me I believe
Code working but i shoot and cant kill
theres a problem, when i try to code an animation and particles in, its spammable and breaks the game, how do i fix this?
can you pleas put in a new discord link thanks
using System.Collections.Generic;
using UnityEngine;
public class Entity : MonoBehaviour
{
[SerializeField] private float StartingHealth;
private float health;
public float Health
{
get
{
return health;
}
set
{
health = value;
Debug.Log(health);
if (health
very helpful thanks👍👍
Great!
Bro mine shows error idk why I did it all perfect
Is the script and in the script the same name?
Thanks soooo much♥
can you give me the script for the entity class plsss
its giving me this error StackOverflowException: The requested operation caused a stack overflow.
entity.get_Health () in :0
I whould love it if i could see the ammo :)
while making the gun damage I noticed that there was an error on enemy.Health -= Damage; does anyone know what is wrong, I am new to unity.
make a script for entitiy or remove line
Holy fucking shit
😁😄😃😃🙂🙃😉🙃😉😉🥵🤢🤢🤢🧐😕🥶🥸🥺🥺🥸😧😰😥😭😭😮😱😱☹🙁😵💫
why am i getting a stack over flow error
It says entity could not be found
tried this, didint work- tried joining the discord to see the code- didint work.. it just says theres an object refrence not set to an instance of an object.. NVM! Set your camera to maincamera in its tags, that should do the trick!
can i have the entity script
Script??
aint no way in hell im typing all that. put it in the description.
All tutorial code is in my discord server
@@Rytech_Dev Doesnt work, its blocked off for me, says im not allowed in the channels for the code
this does not works for me :(
Very easy to understand for begginers, but the code isn't very clean and it might teach them bad habits
theres half an hour of my life i spent that im never getting back. idk wtf all these people are talking abt
jk boo i just needed to add a collider to the camera thx
lol
Not so much a weapon system as it's just how to create a single gun.
year late but you clearly missed the point
Another Dude that thinks he can code but just wastes peoples time, there is not health reference code full of errors, if you need a tutorial look for someone more knowledgeable. SKIP this GUY
nah this works
it works. check if your code is right lol
what unity version are u using
@@cattebayo
using System.Collections.Generic;
using UnityEngine;
public class DamageGun : MonoBehaviour
{
public float Damage;
public float BulletRange;
private Transform PlayerCamera;
private void Start()
{
PlayerCamera = Camera.main.transform;
}
public void Shoot()
{
Ray gunRay = new Ray(PlayerCamera.position, PlayerCamera.forward);
if (Physics.Raycast(gunRay, out RaycastHit hitInfo, BulletRange))
{
if (hitInfo.collider.gameObject.TryGetComponent(out Entity enemy))
{
enemy.Health -= Damage;
}
}
}
}
damage gun
It says that entity couldn't be found