LucasST Posted April 6, 2021 Share Posted April 6, 2021 É Possível utilizar posições do seu mouse para mover objetos ?, testei uns exemplos do próprio fórum mais não está retornando as posições corretas. Obj = {} function teste() if Obj[localPlayer] and isElement(Obj[localPlayer]) then destroyElement(Obj[localPlayer]) Obj[localPlayer] = nil end Obj[localPlayer] = createObject(964, 656.042, -1120.322, 48.605) end addCommandHandler("teste2",teste) addEventHandler( "onClientRender", getRootElement( ), function () if isCursorShowing() and Obj[localPlayer] and isElement(Obj[localPlayer]) then local sx, sy = guiGetScreenSize() local relX, relY = getCursorPosition() local cursorX, cursorY = relX * sx, relY * sy local camX, camY, camZ = getCameraMatrix() local cursorWorldPosX, cursorWorldPosY, cursorWorldPosZ = getWorldFromScreenPosition(cursorX, cursorY, 1000) local z = getGroundPosition(Vector3(getElementPosition(localPlayer))) setElementPosition(Obj[localPlayer], cursorWorldPosX, cursorWorldPosY, z) end end ) Link to comment
Boechat Posted April 7, 2021 Share Posted April 7, 2021 (edited) 18 hours ago, LucasST said: É Possível utilizar posições do seu mouse para mover objetos ?, testei uns exemplos do próprio fórum mais não está retornando as posições corretas. Obj = {} function teste() if Obj[localPlayer] and isElement(Obj[localPlayer]) then destroyElement(Obj[localPlayer]) Obj[localPlayer] = nil end Obj[localPlayer] = createObject(964, 656.042, -1120.322, 48.605) end addCommandHandler("teste2",teste) addEventHandler( "onClientRender", getRootElement( ), function () if isCursorShowing() and Obj[localPlayer] and isElement(Obj[localPlayer]) then local sx, sy = guiGetScreenSize() local relX, relY = getCursorPosition() local cursorX, cursorY = relX * sx, relY * sy local camX, camY, camZ = getCameraMatrix() local cursorWorldPosX, cursorWorldPosY, cursorWorldPosZ = getWorldFromScreenPosition(cursorX, cursorY, 1000) local z = getGroundPosition(Vector3(getElementPosition(localPlayer))) setElementPosition(Obj[localPlayer], cursorWorldPosX, cursorWorldPosY, z) end end ) Tá 1000 de distancia no getWorldFromScreenPosition, talvez esteja funcionando mas o item está indo parar lá na puta que pariu e vc n tá conseguindo ver. Está aparecendo algum erro no debugscript? Edited April 7, 2021 by Boechat Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now