So I have been like two days trying to make a little sword shoot a projectile, But it isn't working, And I'm starting to get tired of trying, So if anyone can tell me how to fix the problem pls help me
(Note, I'm not getting any error, The projectile its simply not showing)
(ik its a dumb question, But im just getting started with c#)
Make sure you are setting item.shoot and item.shootSpeed in the SetDefault() function of your item, like so:
C#:
public override void SetDefaults(){
// Other code here
item.shoot = 0; // Put whatever projectile you want here. For your own custom ones, use ProjectileType<CustomProjectileNameHere>()
item.shootSpeed = 5; // How fast the projectile will travel.
}
Do note that not every projectile can be fired out of a sword like this however. Some have custom AI's disallowing this sort of action. Most projectiles, however, should be fine.
Bruh, I think I did something wrong, Ill just leave the code here, Pls give it a look and tell me what is wrong with it, I would really appreciate it.
I will also put the images, Maybe there is something wrong with them, But I doubt that these are the source of the problem.
C#:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Graphics.Effects;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;
namespace MasterPiece.Items
{
public class CherryBlossomSword : ModItem
{
public override void SetStaticDefaults()
{
// DisplayName.SetDefault("Cherry Blossom Sword"); // By default, capitalization in classnames will add spaces to the display name. You can customize the display name here by uncommenting this line.
Tooltip.SetDefault("Flowers are Deadly after all.");
}
public override void SetDefaults()
{
item.damage = 10;
item.melee = true;
item.width = 50;
item.height = 50;
item.useTime = 23;
item.useAnimation = 23;
item.useStyle = 1;
item.knockBack = 6;
item.value = 10000;
item.rare = 2;
item.UseSound = SoundID.Item1;
item.autoReuse = true;
item.shoot = ProjectileType<CherryBlossomSwordProjectile>();
item.shootSpeed = 8f;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock, 10);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}
C#:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Graphics.Effects;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;
namespace MasterPiece
{
public class CherryBlossomSwordProjectile : ModProjectile
{
public override void SetStaticDefaults()
{
}
public override void SetDefaults()
{
projectile.width = 20;
projectile.height = 20;
projectile.friendly = true;
projectile.melee = true;
projectile.ignoreWater = true;
projectile.tileCollide = false;
projectile.alpha = 255;
projectile.penetrate = -1;
}
// Additional hooks/methods here.
}
}
Bruh, I think I did something wrong, Ill just leave the code here, Pls give it a look and tell me what is wrong with it, I would really appreciate it.
I will also put the images, Maybe there is something wrong with them, But I doubt that these are the source of the problem. View attachment 267985View attachment 267986
C#:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Graphics.Effects;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;
namespace MasterPiece.Items
{
public class CherryBlossomSword : ModItem
{
public override void SetStaticDefaults()
{
// DisplayName.SetDefault("Cherry Blossom Sword"); // By default, capitalization in classnames will add spaces to the display name. You can customize the display name here by uncommenting this line.
Tooltip.SetDefault("Flowers are Deadly after all.");
}
public override void SetDefaults()
{
item.damage = 10;
item.melee = true;
item.width = 50;
item.height = 50;
item.useTime = 23;
item.useAnimation = 23;
item.useStyle = 1;
item.knockBack = 6;
item.value = 10000;
item.rare = 2;
item.UseSound = SoundID.Item1;
item.autoReuse = true;
item.shoot = ProjectileType<CherryBlossomSwordProjectile>();
item.shootSpeed = 8f;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock, 10);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}
C#:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Graphics.Effects;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;
namespace MasterPiece
{
public class CherryBlossomSwordProjectile : ModProjectile
{
public override void SetStaticDefaults()
{
}
public override void SetDefaults()
{
projectile.width = 20;
projectile.height = 20;
projectile.friendly = true;
projectile.melee = true;
projectile.ignoreWater = true;
projectile.tileCollide = false;
projectile.alpha = 255;
projectile.penetrate = -1;
}
// Additional hooks/methods here.
}
}
uh
I might have a peanut brain or something, Because it didn't work ;-; Whatever ill try with a different sword later
Sooo
Tysm for all the help lol, I dunno how to pay you xD, The only think I can offer its my service as a Spriter , So, yeah thanks again
uh
I might have a peanut brain or something, Because it didn't work ;-; Whatever ill try with a different sword later
Sooo
Tysm for all the help lol, I dunno how to pay you xD, The only think I can offer its my service as a Spriter , So, yeah thanks again
Hey there uh, Can you give me a hand with coding again pls? I cant code a dam block and im starting to get headaches bc of this bc how hard could it be to code a little block HOW ON EARTH AM I STRUGGLING WITH A LITTLE BLOCK .. yeahh pls help me ;-;
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.