Yea, I'm kinda stupid and I just got into modding and I'm confused on how to make an animated projectile. (Example: https://terraria.wiki.gg/File:Chlorophyte_Orb_(projectile).gif) Do I just make a gif or should I use a sprite sheet? Also what code do I need? Thanks!
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!
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!
'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?)
'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?)
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?)
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?)
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;
}
}
}
}
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;
}
}
}
}
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.