using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public void weapon
public class PlayerCombat : MonoBehaviour
{
[SerializeField] GameObject[] _weapons;
[SerializeField] float _rateOfFire = 0.2f;
[SerializeField] GameObject _bullet;
[SerializeField] Transform _bulletSpawnPoint;
private bool _isArmed = false;
private bool _isFiring = false;
// Update is called once per frame
void Update()
{
//check to see if armed and if press left mouse button
if (Input.GetMouseButtonDown(0) && _isArmed)
{
//_isFiring set to true
_isFiring = true;
StartCoroutine(Firing());
}
if (Input.GetMouseButtonUp(0) && _isArmed)
{
//_isFiring set to true
_isFiring = false;
}
}
public void SetWeapon(weapon.WeaponType weaponType)
{
if (weaponType == weapon.weaponType.Pistol)
{
_Weapon[0].SetActive(true);
_isArmed = true;
}
}
IEnumerator Firing ()
{
while (_isFiring)
{
//instantiate a bullet
GameObject bullet = Instantiate(_bullet, _bulletSpawnPoint.position, Quaternion.identify);
//fire the bullet in the direction
bullet.GetComponent<Rigibody>().velocity = transform.forward * 15000 * Time.deltaTime;
yield return new WaitForSeconds(_rateOfFire);
}
}
}
I get error Assets\Scripts\Weapons\PlayerCombat.cs(4,19): error CS1002: ; expected
Can someone tell me what it means? i cant understand
I put that there to try to make the error Assets\Scripts\Weapons\PlayerCombat.cs(33,27): error CS0246: The type or namespace name ‘weapon’ could not be found (are you missing a using directive or an assembly reference?) go away because it said missing namespace, and I thought that’s what it meant
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerCombat : MonoBehaviour
{
[SerializeField] GameObject[] _weapon;
[SerializeField] float _rateOfFire = 0.2f;
[SerializeField] GameObject _bullet;
[SerializeField] Transform _bulletSpawnPoint;
private bool _isArmed = false;
private bool _isFiring = false;
// Update is called once per frame
void Update()
{
//check to see if armed and if press left mouse button
if (Input.GetMouseButtonDown(0) && _isArmed)
{
//_isFiring set to true
_isFiring = true;
StartCoroutine(Firing());
}
if (Input.GetMouseButtonUp(0) && _isArmed)
{
//_isFiring set to true
_isFiring = false;
}
}
public void SetWeapon(weapon.WeaponType)
{
if (weaponType == weapon.weaponType.Pistol)
{
_Weapon[0].SetActive(true);
_isArmed = true;
}
}
IEnumerator Firing ()
{
while (_isFiring)
{
//instantiate a bullet
GameObject bullet = Instantiate(_bullet, _bulletSpawnPoint.position, Quaternion.identify);
//fire the bullet in the direction
bullet.GetComponent<Rigibody>().velocity = transform.forward * 15000 * Time.deltaTime;
yield return new WaitForSeconds(_rateOfFire);
}
}
}
I’m gonna say it won’t work until you give it the exact Weapon class it wants, or else engineer your own replacement for Weapon that will suit the needs of this code snippet.