Problem with args.Player.Teleport #2102
-
No matter what numbers I put, even if I put Main.rand.Next, it will always teleport me to this specific spot, what am I doing wrong?
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Tile coordinates are 1/16 of world coordinates (each tile is 16x16 pixels) Multiply both coordinates by 16 to get world coordinates (by whole tile instead of pixels) which is used for npcs, players, and projectiles which you use for Had to do that to teleport a player to wherever they pinged on the map |
Beta Was this translation helpful? Give feedback.
Tile coordinates are 1/16 of world coordinates (each tile is 16x16 pixels)
So you would be teleporting 472 pixels right 111 pixels down from the top left corner of the world (not very far)
https://github.com/tModLoader/tModLoader/wiki/Basic-Tile#coordinates
Multiply both coordinates by 16 to get world coordinates (by whole tile instead of pixels) which is used for npcs, players, and projectiles which you use for
args.Player.Teleport()
eg
args.Player.Teleport(X * 16, Y * 16, 1);
Had to do that to teleport a player to wherever they pinged on the map
https://github.com/Quinci135/MapTeleport/blob/master/MapTeleport/MapTeleport.cs#L55