Keep getting this error and not sure how to fix it unless I am missing something(which is usually the case).
And here is the script the error is coming from.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class GunRecoil : MonoBehaviour
{
public List<WeaponInfo> weaponList = new List<WeaponInfo>();
public WeaponInfo currentWeapon;
public Transform recoilTransform;
public Vector3 currentRecoil1;
public Vector3 currentRecoil2;
public Vector3 currentRecoil3;
public Vector3 currentRecoil4;
private float shootTime = 0f;
void Start ()
{
currentWeapon = weaponList[0];
}
public void Update ()
{
ShootController();
}
public void FixedUpdate()
{
RecoilController();
}
public void ShootController()
{
if (Input.GetButton("Fire1") && Shooting.Instance.clips >0)
{
if (shootTime <= Time.time)
{
shootTime = Time.time + currentWeapon.fireRate;
currentRecoil1 += new Vector3(currentWeapon.recoilRotation.x, Random.Range(-currentWeapon.recoilRotation.y, currentWeapon.recoilRotation.y));
currentRecoil3 += new Vector3(Random.Range(-currentWeapon.recoilKickBack.x, currentWeapon.recoilKickBack.x),
Random.Range(-currentWeapon.recoilKickBack.y, currentWeapon.recoilKickBack.y), currentWeapon.recoilKickBack.z);
}
}
}
public void RecoilController()
{
currentRecoil1 = Vector3.Lerp(currentRecoil1, Vector3.zero, 0.5f);
currentRecoil2 = Vector3.Lerp(currentRecoil2, currentRecoil1, 0.5f);
currentRecoil3 = Vector3.Lerp(currentRecoil3, Vector3.zero, 0.5f);
currentRecoil4 = Vector3.Lerp(currentRecoil4, currentRecoil3, 0.5f);
recoilTransform.localEulerAngles = currentRecoil2;
recoilTransform.localPosition = currentRecoil4;
}
}
[System.Serializable]
public class WeaponInfo
{
public string name = "Weapon";
public float fireRate = 0.1f;
public Transform weaponTransform;
public Vector3 recoilRotation;
public Vector3 recoilKickBack;
}