tModLoader NPC Shooting projectiles issue

Maoz

Terrarian
So the NPC can shoot projectile, but not from the center position (eye of cthulhu, etc.).

It shoots from the right/left position instead, I tried everything to fix this.
I need help.
 
I use this:
the npc will shoot form the center and shoot at the player,
so use Projectile.NewProjectile(npc.Center, velocity, type, npc.damage, 2f); as your projectile.

void Shoot()
{
Vector2 velocity = player.Center - npc.Center; // Get the distance between target and npc.
float magnitude = Magnitude(velocity);
int type = 468;
if (magnitude > 0)
{
velocity *= 18 / magnitude;
}
else
{
velocity = new Vector2(0f, 5f);
}
Projectile.NewProjectile(npc.Center, velocity, type, npc.damage, 2f);
}
 
I use this:
the npc will shoot form the center and shoot at the player,
so use Projectile.NewProjectile(npc.Center, velocity, type, npc.damage, 2f); as your projectile.

void Shoot()
{
Vector2 velocity = player.Center - npc.Center; // Get the distance between target and npc.
float magnitude = Magnitude(velocity);
int type = 468;
if (magnitude > 0)
{
velocity *= 18 / magnitude;
}
else
{
velocity = new Vector2(0f, 5f);
}
Projectile.NewProjectile(npc.Center, velocity, type, npc.damage, 2f);
}
Worked, thanks
 
I want to know how to make my npc shoot a projectile no matter where it shoots from.
Can you please give me the script. Only give me the part of the script where the npc shoots.
You can just paste in this thread. Thank you.
 
Back
Top Bottom