Projectile not coming out right

Saints2000

Terrarian
Anyone know how to make a projectile come out in a specific position or location? Im trying to make gun but when shooting it the projectile comes out beneath the barrel. Sorry for my bad english
 
Anyone know how to make a projectile come out in a specific position or location? Im trying to make gun but when shooting it the projectile comes out beneath the barrel. Sorry for my bad english
Okey i found solvin.
Try it at your SetDefaults
projectile.alpha = 255;

then :
public override void AI() {
projectile.ai[0] += 1f;
if (projectile.ai[0] > 1f)
{
projectile.alpha -= 255;
}
}

First when you shooting - projectile invisible. and then after 1f - 1 frame it set to alpha 0 - that means again visible.
 
There's another, more elegant, solution.
I don't have access to a computer right now, but you can add me Verveine#4718 on discord if you want to discuss it later
 
There's another, more elegant, solution.
I don't have access to a computer right now, but you can add me Verveine#4718 on discord if you want to discuss it later
Oh thank you very much for answer ! But i realy bad speak english.. sad.
I real like terraria modding. started just 3 days ago. and i feelin amazing when trying create something. Thanks people like you for help ! :)
 
Anyone know how to make a projectile come out in a specific position or location? Im trying to make gun but when shooting it the projectile comes out beneath the barrel. Sorry for my bad english
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
Vector2 muzzleOffset = Vector2.Normalize(new Vector2(speedX, speedY)) * 25f;
if (Collision.CanHit(position, 0, 0, position + muzzleOffset, 0, 0))
{
position += muzzleOffset;
}
return true;
}

Add this in your Gun.cs
( this is much better solvin than my first post with projectile.alpha 255 )
 
Last edited:
Back
Top Bottom