Fixed my problem
Can't add script component because the script class cannot be found,can't add script component because the script class cannot be found
I have looked at related questions liked this but none of them worked.
Here is my script:
using UnityEngine;
using System.Collections;
public class GameManager : MonoBehaviour
{
int damageAmount = 5;
float targetDistance;
float allowedRange = 15f;
// Update is called once per frame
void Update()
{
RaycastHit shot;
if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out shot))
{
targetDistance = shot.distance;
if (targetDistance < allowedRange)
{
shot.transform.SendMessage("DeductPoints", damageAmount);
}
}
}
}
This is my error:
Can't add script component 'HandGunDamage' because the script class cannot be found. Make sure that there are no compile errors and that the file name and class name match.
1) I don't see anything mentioning HandGunDamage in the script you posted, are you sure that's the right script?
2) Like the error message says, make sure you have a script whose filename AND whose class name are both HandGunDamage
(capitalization matters), and that there are no errors in that script
3) Unrelated side note: Out of curiosity, why did you repeat your question title twice in the question's title? I keep seeing people doing that and it's been weirding me out for a while
Follow this Question
Related Questions
Scripting Errors 1 Answer
Shoot towards mouse except mouse y 1 Answer
Display GameObjects tag using Raycast 1 Answer
Why isnt my raycast hitting the floor? 0 Answers
How to Destroy game object horizontally and vertically , when hit by a Raycast 0 Answers