#definitely, you should make one, and

1 messages · Page 1 of 1 (latest)

reef mirage
#
using UnityEngine;

[CreateAssetMenu(fileName = "New Gun", menuName = "Weapon/Gun")]
public class GunData : ScriptableObject
{
    public new string name;
    public float damage;
    public float maxDistance;
    public int currentAmmo;
    public int magSize;
    public int maxAmmoReserves;
    public float fireRate;
    public float reloadTime;
    public bool reloading;

    [Header("Animations")]
    public AnimationClip shootAnimation;
    public AnimationClip reloadAnimation;

    public void GiveAmmo(int ammoAmount)
    {
        magSize += ammoAmount; //give ammo to the player when they get ammo (duh)
    }
}```
#

And "GunData"

#

The code is all over the place, I realise. Apologies for that

#

I'm still just learning the relationships between everything in c#

white mural
#

Ok so what issue are you having with this?

#

I mean I'm immediately seeing some things that don't make any sense to me

#
    public void GiveAmmo(int ammoAmount)
    {
        magSize += ammoAmount; //give ammo to the player when they get ammo (duh)
    }```
Why does giving the player ammo increase their magazine size?
reef mirage
#

Yeah lol

#

I don't quite remember what I was doing from before, this script was from quite a few months ago

#

For one thing, reloading doesn't actually reload the weapon

#

And the weapon is in a constant state of reloading as well

#

And yeah, from what you just pointed out, the mag size thing

white mural
#

I mean, I would just take 5 minutes to actually read your code.

#

I found that mag size thing in 5 seconds actually just reading it

#

You need to make sure what you're doing actually makes any sense

reef mirage
#

Ok

#

It was simply just the last edited script i had

white mural
#

The other glaring issue I see here is you seem to have two different scripts keeping track of the same information separately

#

that's a recipe for disaster

#

For GunData, something like magSize and maxAmmoReserves makes sense, but currentAmmo does not make sense on GunData.

Likewise, for the Gun script, it doesn't make sense to track magSize, but it does make sense to track ammoReserves and currentAmmo

#

each of these things should be kept in only one place, and only the place that makes sense.

reef mirage
#

Would you suggest i combine my scriptable object script with the Gun script