is it possible to speed up projectile animations?

FlamingFire

Official Terrarian
based on what i known, 1 frame of an animation is around 5 ticks, is it possible to speed that up, or in other words, make it so it uses less ticks per frame?
 
Is this for your own custom projectile? You can animate it as quickly as you'd like. Or do you want to change vanilla ones?
 
Is this for your own custom projectile? You can animate it as quickly as you'd like. Or do you want to change vanilla ones?
It's for a custom projetile.
 
What's your current animation code for it?
 
Sorry, i can't open my laptop right now, ill send it when i can
 
What's your current animation code for it?
sorry for taking so long. here is my full code:

C#:
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.GameContent;

namespace Vanniluxe.Content.Projectiles.OnFireFlamethrower
{
    public class OnFireFlamethrower : ModProjectile
    {
        public override void SetStaticDefaults() {
            Main.projFrames[Projectile.type] = 7;
        }

        public override void SetDefaults() {
            Projectile.width = 80;
            Projectile.height = 80;

            Projectile.friendly = true;
            Projectile.DamageType = DamageClass.Ranged;
            Projectile.ignoreWater = true;
            Projectile.tileCollide = false;
            Projectile.penetrate = 4;

            Projectile.alpha = 0;
        }

        public override Color? GetAlpha(Color lightColor) {
            return new Color(255, 255, 255, 0) * Projectile.Opacity;
        }

        public override void AI() {
            Projectile.ai[0] += 2f;

            FadeInAndOut();

            Projectile.velocity *= 1;

            if (++Projectile.frameCounter >=8) {
                Projectile.frameCounter = 0;
               
                if (++Projectile.frame >= Main.projFrames[Projectile.type])
                    Projectile.frame = 0;
            }

            if (Projectile.ai[0] >= 100f)
                Projectile.Kill();

           
            Projectile.direction = Projectile.spriteDirection = (Projectile.velocity.X > 0f) ? 1 : -1;

            Projectile.rotation = Projectile.velocity.ToRotation();
           
            if (Projectile.spriteDirection == -1) {
                Projectile.rotation += MathHelper.Pi;
               
            if (Main.netMode != NetmodeID.Server)
            {
                Dust dust = Dust.NewDustPerfect(
                    Position: Projectile.Center,
                    Type: DustID.Torch,
                    Velocity: Vector2.Zero,
                    Alpha: 100,
                    newColor: Color.Orange,
                    Scale: 0.6f
                    );
                dust.noGravity = true;
                dust.fadeIn = -1f;
            }
            }
        }

       
        public void FadeInAndOut() {
           
            if (Projectile.ai[0] <= 90f) {
               
                Projectile.alpha -= 50;
               
                if (Projectile.alpha < 100)
                    Projectile.alpha = 100;

                return;
            }

            Projectile.alpha += 50;
            if (Projectile.alpha > 255)
                Projectile.alpha = 255;
        }

    }
}

i copied it from examplemod in thr github wiki
 
use normal code

C#:
            if (++Projectile.frameCounter >= 8) // 8 is delay in ticks
            {
                Projectile.frameCounter = 0;
                if (++Projectile.frame >= Main.projFrames[Projectile.type])
                    Projectile.frame = 0;
            }
 
Back
Top Bottom