PC How to make an animated projectile?

I just started modding and one a few of my animated items use sprite sheets. I don't know for sure about projectiles but as nearly all of terraria's animated items use vertical sprite sheets I'd say make a sprite sheet for it.
Hope it helps I'm no that good in the subject
 
I just started modding and one a few of my animated items use sprite sheets. I don't know for sure about projectiles but as nearly all of terraria's animated items use vertical sprite sheets I'd say make a sprite sheet for it.
Hope it helps I'm no that good in the subject
Yea I know that I need a sprite sheet but I was getting errors but I found out there's an animated projectile in the examplemod so I'm just going to look at that. Thanks for responding though!
 
Nevermind I'm still getting the error
'Terraria.Projectile' does not contain a definition for 'name' and no extension method 'name' accepting a first argument of type 'Terraria.Projectile' could be found (are you missing a using directive or an assembly reference?)
Can anyone tell me how to fix this?
 
Last edited:
Nevermind I'm still getting the error
'Terraria.Projectile' does not contain a definition for 'name' and no extension method 'name' accepting a first argument of type 'Terraria.Projectile' could be found (are you missing a using directive or an assembly reference?)
Can anyone tell me how to fix this?
Again I'm not that good but I will still try to help. I got this error once and somehow fixed by adding at the beginning of the code "using [reference]". So maybe try adding this ? :/
Hope it helps
Of course replace with "reference" with whatever you might need
 
Again I'm not that good but I will still try to help. I got this error once and somehow fixed by adding at the beginning of the code "using [reference]". So maybe try adding this ? :/
Hope it helps
Of course replace with "reference" with whatever you might need
Doesn't seem to work, but if anyone can figure this out I'll leave the code that's causing problems here and the error.
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.IO;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace KazsMods.Projectiles //We need this to basically indicate the folder where it is to be read from, so you the texture will load correctly
{
public class GhostOrb : ModProjectile
{
public override void SetDefaults()
{
projectile.name = "GhostOrb"; //Name of the projectile, only shows this if you get killed by it
projectile.width = 28; //Set the hitbox width
projectile.height = 28; //Set the hitbox height
projectile.timeLeft = 60; //The amount of time the projectile is alive for
projectile.penetrate = 50; //Tells the game how many enemies it can hit before being destroyed
projectile.friendly = true; //Tells the game whether it is friendly to players/friendly npcs or not
projectile.hostile = false; //Tells the game whether it is hostile to players or not
projectile.tileCollide = true; //Tells the game whether or not it can collide with a tile
projectile.ignoreWater = true; //Tells the game whether or not projectile will be affected by water
projectile.ranged = true; //Tells the game whether it is a ranged projectile or not
projectile.aiStyle = 1; //How the projectile works, this is no AI, it just goes a straight path
projectile.alpha = 255;
projectile.localNPCHitCooldown = -1; // 1 hit per npc max
error CS1061: 'Terraria.Projectile' does not contain a definition for 'name' and no extension method 'name' accepting a first argument of type 'Terraria.Projectile' could be found (are you missing a using directive or an assembly reference?)
 
Yea if you mean brackets then yes.
Doesn't seem to work, but if anyone can figure this out I'll leave the code that's causing problems here and the error.
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.IO;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace KazsMods.Projectiles //We need this to basically indicate the folder where it is to be read from, so you the texture will load correctly
{
public class GhostOrb : ModProjectile
{
public override void SetDefaults()
{
projectile.name = "GhostOrb"; //Name of the projectile, only shows this if you get killed by it
projectile.width = 28; //Set the hitbox width
projectile.height = 28; //Set the hitbox height
projectile.timeLeft = 60; //The amount of time the projectile is alive for
projectile.penetrate = 50; //Tells the game how many enemies it can hit before being destroyed
projectile.friendly = true; //Tells the game whether it is friendly to players/friendly npcs or not
projectile.hostile = false; //Tells the game whether it is hostile to players or not
projectile.tileCollide = true; //Tells the game whether or not it can collide with a tile
projectile.ignoreWater = true; //Tells the game whether or not projectile will be affected by water
projectile.ranged = true; //Tells the game whether it is a ranged projectile or not
projectile.aiStyle = 1; //How the projectile works, this is no AI, it just goes a straight path
projectile.alpha = 255;
projectile.localNPCHitCooldown = -1; // 1 hit per npc max
error CS1061: 'Terraria.Projectile' does not contain a definition for 'name' and no extension method 'name' accepting a first argument of type 'Terraria.Projectile' could be found (are you missing a using directive or an assembly reference?)

Dear Kazz tmodloader doesn't use projectile.name anymore it uses DisplayName.SetDefault("Insert name here") i hope this helps you
 
Has Anyone found a way to do this yet? I also need help with it. Can someone share the code?
Here is the code for an example projectile that animates through its sprite sheet. This example is just a clone of the wooden arrow, obviously change it to whatever you want your projectile to be.
C#:
public class ExampleAnimatedProjectile : ModProjectile
{
    public override void SetStaticDefaults()
    {
        Main.projFrames[projectile.type] = 2; //The number of frames the sprite sheet has
    }

    public override void SetDefaults()
    {
        projectile.CloneDefaults(ProjectileID.WoodenArrowFriendly);
        aiType = ProjectileID.WoodenArrowFriendly;
    }
    public override void AI()
    {
        //This will cycle through all of the frames in the sprite sheet
        int frameSpeed = 2; //How fast you want it to animate
        projectile.frameCounter++;
        if (projectile.frameCounter >= frameSpeed)
        {
            projectile.frameCounter = 0;
            projectile.frame++;
            if (projectile.frame >= Main.projFrames[projectile.type])
            {
                projectile.frame = 0;
            }
        }
    }
}
There is also an example in this tModLoader guide: Basic Projectile · tModLoader/tModLoader Wiki
 
Thanks For Your Help! I Really Appreciate It.
Here is the code for an example projectile that animates through its sprite sheet. This example is just a clone of the wooden arrow, obviously change it to whatever you want your projectile to be.
C#:
public class ExampleAnimatedProjectile : ModProjectile
{
    public override void SetStaticDefaults()
    {
        Main.projFrames[projectile.type] = 2; //The number of frames the sprite sheet has
    }

    public override void SetDefaults()
    {
        projectile.CloneDefaults(ProjectileID.WoodenArrowFriendly);
        aiType = ProjectileID.WoodenArrowFriendly;
    }
    public override void AI()
    {
        //This will cycle through all of the frames in the sprite sheet
        int frameSpeed = 2; //How fast you want it to animate
        projectile.frameCounter++;
        if (projectile.frameCounter >= frameSpeed)
        {
            projectile.frameCounter = 0;
            projectile.frame++;
            if (projectile.frame >= Main.projFrames[projectile.type])
            {
                projectile.frame = 0;
            }
        }
    }
}
There is also an example in this tModLoader guide: Basic Projectile · tModLoader/tModLoader Wiki
 
Back
Top Bottom