POCKETS
Terrarian
Alright, so I am attempting to spawn two projectiles from what's known as a "held projectile" (basically a weapon, but it's a projectile that rotates just like a normal weapon item, and is stuck to the player).
Anyhow, normally, I would spawn these two projectiles using the item's
Here is the original calculation from the
As you can see, I am shooting two projectiles, offset from each other by a small margin.
The problem is, now that I am shooting these projectiles from a held projectile, and not inside the
Just for reference, here's how I am handling the position and rotation of the held projectile -
Anyhow, normally, I would spawn these two projectiles using the item's
Shoot()
hook. However, I can't do that anymore, since this particular issue has to do with the 1.4 alpha, and the Shoot()
hook doesn't give me the functionality required to make this work (there's more to it than that, but I'll just leave it at that).Here is the original calculation from the
Shoot()
hook I was using in 1.3 tMod -
C#:
Vector2 velocity = new Vector2(10, 10); // I added this in the held projectile because I needed a velocity. This wasn't used in the Shoot() hook
float startRadius = 5f;
Vector2 direction = Vector2.Normalize(new Vector2(velocity.X, velocity.Y));
direction *= startRadius;
Vector2 firePosition1 = direction.RotatedBy(0.9f);
Vector2 firePosition2 = direction.RotatedBy(- 0.9f);
Projectile.NewProjectile(Projectile.GetProjectileSource_FromThis(), Projectile.Center.X + firePosition1.X, Projectile.Center.Y + firePosition1.Y, velocity.X, velocity.Y, ModContent.ProjectileType<ModProjectile>(), Projectile.damage, Projectile.knockBack, player.whoAmI);
Projectile.NewProjectile(Projectile.GetProjectileSource_FromThis(), Projectile.Center.X + firePosition2.X, Projectile.Center.Y + firePosition2.Y, velocity.X, velocity.Y, ModContent.ProjectileType<ModProjectile>(), Projectile.damage, Projectile.knockBack, player.whoAmI);
As you can see, I am shooting two projectiles, offset from each other by a small margin.
The problem is, now that I am shooting these projectiles from a held projectile, and not inside the
Shoot()
hook, this no longer works. Well, it does shoot the projectiles, but at a 45 degree angle down and to the right. The projectiles are still offset from each other, as they should be, but I believe I need to factor in the rotation of the held projectile here, and I can't seem to figure out how to do that. My math skills are... lacking, so I was hoping someone could help me out. Just for reference, here's how I am handling the position and rotation of the held projectile -
C#:
Projectile.velocity = Vector2.Zero;
Projectile.position.X = player.Center.X - Projectile.width / 2;
Projectile.position.Y = player.Center.Y + player.gfxOffY - Projectile.height / 2;
if (Main.myPlayer == Projectile.owner && Projectile.timeLeft > 2)
{
Projectile.ai[0] = (Main.MouseWorld - player.Center).ToRotation();
}
Projectile.rotation = Projectile.ai[0];