I use some code to calculate the path of a sprite. The front of the sprite texture is pointing upwards and that is the direction I want to move my sprite, but as it is now, the direction of the sprite is to the right of the sprite texture!? So when I rotate it a move in a new direction it’s moves sideways. I hope my question isn’t unclear? Help is preciated if there is a solution to change so the direction is pointing upwards of the sprite texture.
public override void Update()
{
direction = new Vector2((float)Math.Cos(rotation), (float)Math.Sin(rotation));
position += direction * speed;
}
public virtual void Draw(SpriteBatch spriteBatch)
{
spriteBatch.Draw(texture, position, null, Color.White, rotation, origin, scale, SpriteEffects.None, 0f);
}
Simple fix:
Just subtract (or add) 90 degrees from the rotation when you draw it