tModLoader How to fix swords not being directly in the hand?

User_Name1

Terrarian
so, i'm making a sword and i noticed that when it's texture is very big it's like floating a little bit away from the hand. how to fix that?
 
You can use ModItem.UseStyle() to modify the visual location and visual rotation of swung weapons. To do this, you change the value of player's Player.itemLocation and Player.itemRotation, typically based on values of Player.itemAnimation and Player.itemAnimationMax.

If you don't feel like figuring all of that out, here is a formula thingy I made:
C#:
public override void UseStyle(Player player, Rectangle heldItemFrame)
{
    float xOffset = 0; // How much farther away from the player you want your item to visually be
    float yOffset = 0; // How much lower you want your item to visually be
    Vector2 itemOffset =  new Vector2(xOffset * player.direction, yOffset).RotatedBy(player.itemRotation);
    player.itemLocation += itemOffset;
}
Just copy and paste this into your ModItem's class and change the values of xOffset and yOffset to position your item how you would like!
Increasing the value of xOffset will move the item farther away from the player (you probably want a negative number), and increasing the value of yOffset will move the item more downward (you may want a positive number).
 
You can use ModItem.UseStyle() to modify the visual location and visual rotation of swung weapons. To do this, you change the value of player's Player.itemLocation and Player.itemRotation, typically based on values of Player.itemAnimation and Player.itemAnimationMax.

If you don't feel like figuring all of that out, here is a formula thingy I made:
C#:
public override void UseStyle(Player player, Rectangle heldItemFrame)
{
    float xOffset = 0; // How much farther away from the player you want your item to visually be
    float yOffset = 0; // How much lower you want your item to visually be
    Vector2 itemOffset =  new Vector2(xOffset * player.direction, yOffset).RotatedBy(player.itemRotation);
    player.itemLocation += itemOffset;
}
Just copy and paste this into your ModItem's class and change the values of xOffset and yOffset to position your item how you would like!
Increasing the value of xOffset will move the item farther away from the player (you probably want a negative number), and increasing the value of yOffset will move the item more downward (you may want a positive number).
thanks! i did seem to figure out an another solution which atleast worked for the weapon i was making, which was just not upscaling it to match how every texture has 4 pixels for one but instead just making the scale 2f. it does make the weapon look small when you throw it out so not a perfect solution
 
thanks! i did seem to figure out an another solution which atleast worked for the weapon i was making, which was just not upscaling it to match how every texture has 4 pixels for one but instead just making the scale 2f. it does make the weapon look small when you throw it out so not a perfect solution
Can’t you just manually change the sprite itself then? Add a few pixels to the blade?
 
Can’t you just manually change the sprite itself then? Add a few pixels to the blade?
You can, but with large swords, the image still may be miss-positioned. Even if the handle is entirely in the bottom left, you may still have issues.
 
Back
Top Bottom