View attachment 295632 so i am trying to make my first animated projectile, im having a lot of trouble with it. only 4 frames and it has 2 pixles between each frame ( 1 terraria sized pixle ). for this im making it come out of a spear. i dont know how to make it work so help would be very kind.
code for the projectile:
namespace Modding2.Projectiles
{
class cursedball : ModProjectile
{
public override void SetStaticDefaults()
{
Main.projFrames[projectile.type] = 4;
if (++projectile.frameCounter >= 5)
{
projectile.frameCounter = 0;
if (++projectile.frame >= 4)
{
projectile.frame = 0;
}
}
}
public override void SetDefaults()
{
projectile.Name = "cursedball";
projectile.width = 28;
projectile.height = 28;
projectile.friendly = true;
projectile.tileCollide = true;
projectile.magic = true;
projectile.timeLeft = 600;
projectile.light = 1f;
projectile.aiStyle = 0;
projectile.ignoreWater = true;
Main.projFrames[projectile.type] = 4;
}
public override void AI()
{
projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f;
}
}
}
code for the thing thats firing it:
public class cursedspear : ModItem
{
public override void SetStaticDefaults()
{
// DisplayName.SetDefault("ExampleSword");
}
public override void SetDefaults()
{
item.damage = 32;
item.melee = true;
item.width = 40;
item.height = 40;
item.useTime = 20;
item.useAnimation = 20;
item.useStyle = 1;
item.knockBack = 3;
item.value = 10000;
item.rare = 3;
item.UseSound = SoundID.Item1;
item.autoReuse = true;
item.shoot = mod.ProjectileType("cursedball");
item.shootSpeed = 8f;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.Wood, 10);
recipe.AddIngredient(mod.ItemType("Steel"), 8);
recipe.AddTile(TileID.Anvils);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}