Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Goto
- -- by SukkaiPoppuGo
- assert(pocket, "Require pocket computer")
- local target = vector.new(-100, 50, -25)
- local playerData = pocket.getEntity()
- local player = vector.new( playerData.x, playerData.y, playerData.z )
- --https://math.stackexchange.com/questions/42640/calculate-distance-in-3d-space
- function distance(A, B)
- return math.sqrt(math.pow(B.x - A.x, 2) + math.pow(B.y - A.y, 2) + math.pow(B.z - A.z, 2))
- end
- local function isColinear( A, B )
- return A.x * B.z == B.x * A.z
- end
- local function convertXZToScreen(x, z, yaw)
- local angle = math.rad(-yaw % 360)
- local px = math.cos(angle) * -x - math.sin(angle) * -z
- local py = math.sin(angle) * -x + math.cos(angle) * -z
- return px, py
- end
- local function abs2rel(A, B)
- return B - A
- end
- local Rel = abs2rel(player, target)
- 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