I want to make weapon get its data from scriptable object, but when i want to make the child of this object use a child of that scriptable object it all breaks.> Child of Weapon
public class ProjectileLauncher : Weapon
{
[SerializeField] new ProjectileLauncherData weaponData;
GameObject projectile;
GameObject lastProjectile;
Vector2 projectileAmount;
float projectileDelay;
float projectileSpread;
void Start()
{
projectile = weaponData.projectile;
lastProjectile = weaponData.lastProjectile;
projectileAmount = weaponData.projectileAmount;
projectileDelay = weaponData.projectileDelay;
projectileSpread = weaponData.projectileSpread;> Weapon
public class Weapon : MonoBehaviour
{
protected float minDis;
protected float maxDis;
protected Vector2 attackCooldown;
[SerializeField] protected WeaponData weaponData;
[SerializeField] protected Transform shootPoint;
public Transform joinPoint;
protected float attackCooldownLeft;
protected Enemy enemy;
void Start()
{
minDis = weaponData.minDis;
maxDis = weaponData.maxDis;
attackCooldown = weaponData.attackCooldown;
attackCooldownLeft = Random.Range(attackCooldown.x, attackCooldown.y);
}
> Child of WeaponData
[CreateAssetMenu]
public class ProjectileLauncherData : WeaponData
{
public GameObject projectile;
public GameObject lastProjectile;
public Vector2 projectileAmount;
public float projectileDelay;
public float projectileSpread;
}
> WeaponData
[CreateAssetMenu]
public class WeaponData : ScriptableObject
{
public float minDis;
public float maxDis;
public Vector2 attackCooldown;
}
I get the following error,
![alt text][1]
Thanks for help in advance.
[1]: /storage/temp/199645-screenshot-2022-09-08-at-180854.png
↧