this question may be asked a few times but the answers don’t solve my problem
so I have this script
var Price = 1500;
var Bought = false;
var Player : GameObject;
function Update () {
}
function OnTriggerEnter(col : Collider){
if(col.tag == "Player"){
if(Input.GetKey(KeyCode.F)){
Player.GetComponent.<RaycastShooting>().GotGunTwo = true;
}
}
}
the object that’s going to be player will have a RaycastShooting script attached to it.
but unity outputs this error
Assets/Yvalson Scripts/BuyWallWeapon.js(12,30): BCE0018: The name ‘RaycastShooting’ does not denote a valid type (‘not found’). Did you mean ‘System.Net.Cache.RequestCacheLevel’?
I did it earlier with another script and that worked well why isn’t it working now
for refference here is the raycastshooting script that is called for
var Damage = 10;
var FireRate = 0.1F;
var NextFire = 0.0F;
var BulletRange = 200;
var ClipAk = 30;
var TotalBulletsAk = 90;
var ClipUMP = 45;
var TotalBulletsUMP = 135;
var ReloadTime = 1;
var Nifes = 3;
var SpreadFactor : float = 0;
var AimSpread : float = 0.01;
var HipFireSpread : float = 0.01;
var AimCamera : GameObject;
var BulletHole : GameObject;
var Nife : GameObject;
var NifeSpawn : GameObject;
var IsReloading = false;
var GunFireSound : AudioClip;
var EmptyGunSound : AudioClip;
var Gun : GameObject;
var GunReloadSound : AudioClip;
var AnimationPlayed = false;
var MuzzleFlash : GameObject;
var GunTwo : GameObject;
var ActiveGun = 2;
var GotGunTwo = false;
function Start() {
GunReloadAnimation = Gun.GetComponent.<Animator>();
}
function Update() {
MuzzleFlash = gameObject.FindWithTag("MuzzleFlash");
MuzzleFlash.GetComponent.<Renderer>().enabled = false;
AimCamera.GetComponent.<Crosshair>().enabled = true;
SpreadFactor = HipFireSpread;
if(Input.GetButton("Fire2")){
AimCamera.GetComponent.<Crosshair>().enabled = false;
SpreadFactor = AimSpread;
}
if(ActiveGun == 1){
if(Input.GetButton("Fire1") && Time.time > NextFire && ClipAk > 0){
NextFire = Time.time + FireRate;
GetComponent.<AudioSource>().clip = GunFireSound;
GetComponent.<AudioSource>().time = 0.2f;
GetComponent.<AudioSource>().Play();
Rayshooting();
ClipAk --;
}
else if(ClipAk == 0 && TotalBulletsAk != 0){
GetComponent.<AudioSource>().time = 0.4f;
GetComponent.<AudioSource>().clip = GunReloadSound;
GetComponent.<AudioSource>().Play();
ReloadAk();
}
else if(Input.GetButtonDown("Fire1") && ClipAk == 0 && TotalBulletsAk == 0){
EmptySound();
}
if(Input.GetKey(KeyCode.R) && ClipAk < 30 && TotalBulletsAk != 0 && IsReloading == false) {
GetComponent.<AudioSource>().time = 0.4f;
GetComponent.<AudioSource>().clip = GunReloadSound;
GetComponent.<AudioSource>().Play();
ReloadAk();
}
}
if(ActiveGun == 2){
if(Input.GetButton("Fire1") && Time.time > NextFire && ClipUMP > 0){
NextFire = Time.time + FireRate;
GetComponent.<AudioSource>().clip = GunFireSound;
GetComponent.<AudioSource>().time = 0.2f;
GetComponent.<AudioSource>().Play();
Rayshooting();
ClipUMP --;
}
else if(ClipUMP == 0 && TotalBulletsUMP != 0){
GetComponent.<AudioSource>().time = 0.4f;
GetComponent.<AudioSource>().clip = GunReloadSound;
GetComponent.<AudioSource>().Play();
ReloadUMP();
}
else if(Input.GetButtonDown("Fire1") && ClipUMP == 0 && TotalBulletsUMP == 0){
EmptySound();
}
if(Input.GetKey(KeyCode.R) && ClipUMP < 45 && TotalBulletsUMP != 0 && IsReloading == false) {
GetComponent.<AudioSource>().time = 0.4f;
GetComponent.<AudioSource>().clip = GunReloadSound;
GetComponent.<AudioSource>().Play();
ReloadUMP();
}
}
if(Input.GetKeyDown(KeyCode.E) && Nifes > 0){
Instantiate(Nife, NifeSpawn.transform.position, NifeSpawn.transform.rotation);
Nifes --;
}
if(GotGunTwo == true){
if(Input.GetKeyDown(KeyCode.Alpha1)){
WeaponSwitch();
}
}
}
function Rayshooting() {
{
MuzzleFlash.GetComponent.<Renderer>().enabled = true;
yield WaitForSeconds(0.02);
MuzzleFlash.GetComponent.<Renderer>().enabled = false;
}
var direction : Vector3 = transform.forward;
direction.x += Random.Range(-SpreadFactor, SpreadFactor);
direction.y += Random.Range(-SpreadFactor, SpreadFactor);
direction.z += Random.Range(-SpreadFactor, SpreadFactor);
Debug.DrawRay(transform.position,direction * BulletRange);
var hit : RaycastHit;
bHit = Physics.Raycast(transform.position,direction,hit,BulletRange);
if (bHit && hit.transform.gameObject.tag == "Enemy"){
hit.transform.SendMessage("DamageTaken", Damage, SendMessageOptions.DontRequireReceiver);
}
else if (bHit && hit.transform.gameObject.tag == "Buildings" || "Buildings2"){
var CloneHole = Instantiate(BulletHole, hit.point, Quaternion.LookRotation(hit.normal));
Destroy(CloneHole, 5);
}
}
function ReloadAk() {
if(ActiveGun == 1){
Gun.GetComponent.<Animation>().Play("Reload");
}
else if(ActiveGun == 2){
GunTwo.GetComponent.<Animation>().Play("Reload UMP");
}
yield WaitForSeconds(ReloadTime);
if(ClipAk == 0 && TotalBulletsAk >= 30){
ClipAk = 30;
TotalBulletsAk -= 30;
}
if(ClipAk == 0 && TotalBulletsAk << 30){
ClipAk = TotalBulletsAk;
TotalBulletsAk = TotalBulletsAk - TotalBulletsAk;
}
if(ClipAk != 0 && TotalBulletsAk >= 30 - ClipAk){
TotalBulletsAk = TotalBulletsAk - (30 - ClipAk);
ClipAk = 30;
}
else if(ClipAk != 0 && TotalBulletsAk << 30 - ClipAk){
ClipAk = ClipAk + TotalBulletsAk;
TotalBulletsAk = 0;
}
}
function ReloadUMP() {
if(ActiveGun == 1){
Gun.GetComponent.<Animation>().Play("Reload");
}
else if(ActiveGun == 2){
GunTwo.GetComponent.<Animation>().Play("Reload UMP");
}
yield WaitForSeconds(ReloadTime);
if(ClipUMP == 0 && TotalBulletsUMP >= 45){
ClipUMP = 45;
TotalBulletsUMP -= 45;
}
if(ClipUMP == 0 && TotalBulletsUMP << 45){
ClipUMP = TotalBulletsUMP;
TotalBulletsUMP = TotalBulletsUMP - TotalBulletsUMP;
}
if(ClipUMP != 0 && TotalBulletsUMP >= 45 - ClipUMP){
TotalBulletsUMP = TotalBulletsUMP - (45 - ClipUMP);
ClipUMP = 45;
}
else if(ClipUMP != 0 && TotalBulletsUMP << 45 - ClipUMP){
ClipUMP = ClipUMP + TotalBulletsUMP;
TotalBulletsUMP = 0;
}
}
function EmptySound(){
GetComponent.<AudioSource>().time = 0.0f;
GetComponent.<AudioSource>().volume = 1;
GetComponent.<AudioSource>().clip = EmptyGunSound;
GetComponent.<AudioSource>().Play();
}
function WeaponSwitch(){
if(Gun.active == true){
Gun.GetComponent.<Animation>().Play("WeaponOut");
yield WaitForSeconds(0.5);
Gun.SetActive(false);
GunTwo.SetActive(true);
GunTwo.GetComponent.<Animation>().Play("WeaponIn");
ActiveGun = 2;
}
else{
GunTwo.GetComponent.<Animation>().Play("WeaponOut");
yield WaitForSeconds(0.5);
GunTwo.SetActive(false);
Gun.SetActive(true);
Gun.GetComponent.<Animation>().Play("WeaponIn");
ActiveGun = 1;
}
}
as you can see in the raycastshooting script I used the same thing here
var AimCamera : GameObject;
AimCamera.GetComponent.<Crosshair>().enabled = true;
this does not put any errors at all what’s wrong?