# Moving sprite from one vector to the other

I'm developing a game where enemy can shoot bullets towards the player. I'm using 2 vector that is normalized later to determine where the bullets will go.

Here is the code where enemy shoots:

private void UpdateCommonBullet(GameTime gt)
{
foreach (CommonEnemyBullet ceb in bulletList)
{
ceb.pos += ceb.direction * 1.5f * (float)gt.ElapsedGameTime.TotalSeconds;
if (ceb.pos.Y >= 600) ceb.hasFired = false;
}

for (int i = 0; i < bulletList.Count; i++)
{
if (!bulletList[i].hasFired)
{
bulletList.RemoveAt(i);
i--;
}
}
}


And here is where i get the direction (in the constructor of the bullet):

direction = Global.currentPos - this.pos;
direction.Normalize();


Global.currentPos is a Vector2 where currently player is located, and is updated eveytime the player moves.

This all works fine except that the bullet won't go to player's location. Instead, it tends goes to the "far right" of the player's position.

I think it might be the problem where the bullet (this.pos in the direction) is created (at the position of the enemy). But I found no solution of it, please help me.

• could you post a "how it´s supposed to be" picture and one "what is now"? would help alot! – Tordin Jul 12 '13 at 9:28
• can't post picture due to my reputation. But let's say my screen is (800, 800), my player is now at (100, 100), enemy come from (100, 100), but the bullet they sprayed is as if my player is at (900, 100) so the bullet go to (900, 100) – user2002495 Jul 12 '13 at 9:31
• you can link them, and post it on some specific image site. – Tordin Jul 12 '13 at 9:45
• I "quite" solved the problem already. But not satisfied. Here you go. Expected : postimg.org/image/h2cld6hfn Reality: postimg.org/image/uxavvnbur – user2002495 Jul 12 '13 at 10:04
• i think your problem is that you are using the texture position and not actualy the center cordinates. to fix this, adjust it with using Width / 2 & height / 2. – Tordin Jul 12 '13 at 10:16