Error CS0246 : Projectile could not be found

kingofthechairs

Terrarian
Basically the error i'm having is my gun (Blobthrower) shoots a projectile (Blobthrowerbubble) using the following code:
C#:
Item.shoot = ModContent.ProjectileType<BlobThrowerbubble>();
Somehow it can't find the projectile. I'll put the projectile's code below
C#:
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
using Microsoft.Xna.Framework;

namespace BruceAdds.Projectiles.BlobThrowerbubble
{
    public class BlobThrowerbubble : ModProjectile
    {
        
        public override void SetDefaults()
        {
            Projectile.DamageType = DamageClass.Ranged; // Damage class projectile uses
            Projectile.scale = 1f; // Projectile scale multiplier
            Projectile.penetrate = 1; // How many hits projectile have to make before it dies. 3 means projectile will die on 3rd enemy. Setting this to 0 will make projectile die instantly
            Projectile.aiStyle = 0; // AI style of a projectile. 0 is default bullet AI
            Projectile.width = Projectile.height = 6; // Hitbox of projectile in pixels
            Projectile.friendly = true; // Can hit enemies?
            Projectile.hostile = false; // Can hit player?
            Projectile.timeLeft = 90; // Time in ticks before projectile dies
            Projectile.light = 1f; // How much light projectile provides
            Projectile.ignoreWater = true; // Does the projectile ignore water (doesn't slow down in it)
            Projectile.tileCollide = true; // Does the projectile collide with tiles, like blocks?
            
        }
    }
}

I'll also be putting the weapon's code down below if it's needed.
C#:
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
using Microsoft.Xna.Framework;

namespace BruceAdds.Items.BlobthrowerSA
{
    public class Blobthrower : ModItem{
        public override void SetDefaults()
        {
            Item.width = 33;
            Item.height = 28;
            Item.scale = 1.0f;
            Item.useStyle = ItemUseStyleID.Shoot; // Use style for guns
            Item.rare = 4;

            Item.damage = 20; // Gun damage + bullet damage = final damage
            Item.DamageType = DamageClass.Ranged;
            Item.useTime = 1; // Delay between shots.
            Item.useAnimation = 15; // How long shoot animation lasts in ticks.
            Item.knockBack = 0.5f; // Gun knockback + bullet knockback = final knockback
            Item.autoReuse = true;

            Item.value = 100000;
            Item.UseSound = SoundID.Item11;

            Item.noMelee = true; // Item not dealing damage while held, we don’t hit mobs in the head with a gun
            Item.shoot = ModContent.ProjectileType<BlobThrowerbubble>(); // What kind of projectile the gun fires, does not mean anything here because it is replaced by ammo
            Item.shootSpeed = 12f; // Speed of a projectile. Mainly measured by eye
            Item.useAmmo = ModContent.ItemType<RadWaste>(); // What ammo gun uses
        }
    }
}
 
I've already done these things to try and fix the error:

-Fix the filepaths;
-Add the projectile to its own folder;
-Renaming the projectile;
-Putting the projectile on the ammo instead of the gun;
-Add more directives
 
Nevermind i just had to add the projectile's filepath as a directive into the gun
 
u need to start learn c# before even copy others code i guess
 
Back
Top Bottom