Advertisement
skypop

CC Goto

Aug 10th, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.92 KB | None | 0 0
  1. -- Goto
  2. -- by SukkaiPoppuGo
  3.  
  4. assert(pocket, "Require pocket computer")
  5.  
  6. local target = vector.new(-100, 50, -25)
  7. local playerData = pocket.getEntity()
  8. local player = vector.new( playerData.x, playerData.y, playerData.z )
  9.  
  10. --https://math.stackexchange.com/questions/42640/calculate-distance-in-3d-space
  11. function distance(A, B)
  12.     return math.sqrt(math.pow(B.x - A.x, 2) + math.pow(B.y - A.y, 2) + math.pow(B.z - A.z, 2))
  13. end
  14.  
  15. local function isColinear( A, B )
  16.    return A.x * B.z == B.x * A.z
  17. end
  18.  
  19. local function convertXZToScreen(x, z, yaw)
  20.     local angle = math.rad(-yaw % 360)
  21.     local px = math.cos(angle) * -x - math.sin(angle) * -z
  22.     local py = math.sin(angle) * -x + math.cos(angle) * -z
  23.     return px, py
  24. end
  25.  
  26. local function abs2rel(A, B)
  27.     return B - A
  28. end
  29.  
  30. local Rel = abs2rel(player, target)
  31.  
  32. local px, py = convertXZToScreen(Rel.x, Rel.z, player.yaw) --si player.yaw existe bien sous ce nom
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement