• Journey's End on PC - Find info here and here. Please report bugs and issues for PC 1.4 and 1.4.1 to Re-Logic here.
  • Journey's End on Mobile - Find info here. Report bugs for Mobile 1.4 to DR Studios at this link and give as much detail as possible.
  • 1.4 will bring many changes to the PC version. We strongly advise making plans to back up your worlds and players prior to updating your game. More details here.
  • Console and Switch - The latest news can be found here. To report a bug, please use this link.

tAPI [Tutorial] Projectile Guide and Implementation

Sin Costan

Eye of Cthulhu
How do I make a modded projectile pass through tiles, but becomes solid when it reaches the cursor? I'm using tModLoader, btw. :)
There is a tModLoader version of this tutorial, just post in there if you have tModLoader related questions. You can find it in my sigature under "My tModLoader Stuff".

To answer your question now, if you mean by no tile collision and then tile collision, then just use Shoot() hook, spawn a new Projectile with Projectile.NewProjectile and add the mouse positions for the last two parameters of that function. Note, things will act funky if you are using a vanilla AI style if you store the mouse positions in the projectile's AI slots. Afterwards, we go onto your projectile, in which for your AI, we want the defaults to include tile collision, meaning tileCollide = false. After wards you can just check the relative distance between the projectile and the point and then turn on tile collision.

Here is essentially what you want... But try to do what I said above before looking at the code so you can learn how to do it.

        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
            //Get mouse position in the screen
            Vector2 relativePoint = Main.player[projectile.owner].RotatedRelativePoint(Main.player[projectile.owner].MountedCenter, true);
            float mouseX = (float)Main.mouseX + Main.screenPosition.X - relativePoint.X;
            float mouseY = (float)Main.mouseY + Main.screenPosition.Y - relativePoint.Y;
            //Spawn a new projectile with the same stuff as the params except adding in the mouse positions in the AI of the projectile
            Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, 0, knockBack, player.whoAmI, mouseX, mouseY);
            //Makes sure it doesn't spawn the original projectile
            return false;
        public override void AI()
            //Get the distance
            float dToX = projectile.ai[0] - projectile.Center.X;
            float dToY = projectile.ai[1] - projectile.Center.X;
            float distance = (float)System.Math.Sqrt((double)(dToX * dToX + dToY * dToY));
            //If the distance between the projectile and the point is less than 100 pixels, then it will collide with tiles
            if(distance < 100f)
                projectile.tileCollide = true;


Hello I am quite new to coding and especially Terraria coding. I am trying to find how to do a spinning throwing weapon, I couldn't find any tutorials for it so I thought this would a reliable source to ask. So please how do you make a throwing weapon spin?
(Extra Question) With my throwing weapon I used a tutorial but the tutorial was for a spear and my weapon was more like a endless shuriken and they had a "Dust" effect when the spear collided with a tile or enemy but it was in the shape of a spear but I would like more of a explosion like dust effect but as I said I am quite a Newbie ( I did a bit of coding in Unity(Only Beginner Stuff). Sorry for disturbing you.:D

Oh whoops, sorry this is in the tAPI forum Projectile guide page. This is for T Mod Loader, I will put this on the T Mod Loader page too. Sorry!
Top Bottom