iwalidza Posted January 11, 2022 Share Posted January 11, 2022 some places getGroundPosition not work well how i can fix it Link to comment
The_GTA Posted January 11, 2022 Share Posted January 11, 2022 Hello iwalidza, it could be that the position does not have their collision loaded yet, thus not allowing a ground-position query to function. In that case you should move the camera close to your point of request, wait for a frame until the game has loaded the surrounding area and then use that request in further code. there are area on the map of which the ground position might not be of interest. In that case you could try checking against the water-surface instead or try to query the position of a possibly-defined roof. Link to comment
iwalidza Posted January 11, 2022 Author Share Posted January 11, 2022 8 minutes ago, The_GTA said: Hello iwalidza, it could be that the position does not have their collision loaded yet, thus not allowing a ground-position query to function. In that case you should move the camera close to your point of request, wait for a frame until the game has loaded the surrounding area and then use that request in further code. there are area on the map of which the ground position might not be of interest. In that case you could try checking against the water-surface instead or try to query the position of a possibly-defined roof. I don't know how I can use it I think the area not be of interest Link to comment
The_GTA Posted January 11, 2022 Share Posted January 11, 2022 Can you show us the script that has to be fixed? Link to comment
iwalidza Posted January 11, 2022 Author Share Posted January 11, 2022 2 hours ago, The_GTA said: Can you show us the script that has to be fixed? local sw, sh = guiGetScreenSize () local isEnable = false local oneTick = false local currentIndex = 1 local levelVar = 0 setDevelopmentMode(true) local loadList = { {9990,"foundation"}, {9991,"door"}, {9992,"floor"}, {9993,"stair"}, {9994,"wall"}, {9995,"walldoor"}, {9996,"wallwindow"}, } function findRotation( x1, y1, x2, y2 ) local t = -math.deg( math.atan2( x2 - x1, y2 - y1 ) ) return t < 0 and t + 360 or t end function onStart() for i = 1 ,#loadList do col_floors = engineLoadCOL ( "models/"..loadList[i][2]..".col" ) engineReplaceCOL ( col_floors, loadList[i][1] ) txd_floors = engineLoadTXD ( "models/texture.txd" ) engineImportTXD ( txd_floors, loadList[i][1] ) dff_floors = engineLoadDFF ( "models/"..loadList[i][2]..".dff" ) engineReplaceModel ( dff_floors, loadList[i][1] ) end editMode = dxCreateShader('shader.fx', 0, 0, false, 'object') local r, g, b, a = 19, 70, 209,200 dxSetShaderValue ( editMode, "gRedColor", r/255 ) dxSetShaderValue ( editMode, "gGrnColor", g/255 ) dxSetShaderValue ( editMode, "gBluColor", b/255 ) dxSetShaderValue ( editMode, "gAlpha", a/255 ) end addEventHandler("onClientResourceStart", resourceRoot, onStart) function BuildingEditCreate (x,y,z) local player = getLocalPlayer() local matrix = player.matrix editObject = createObject(9990 ,player.matrix.position + player.matrix.forward * 2,0,0,0,true) engineApplyShaderToWorldTexture(editMode,'*',editObject) end function enableEdit () isEnable = not isEnable oneTick = true end bindKey("E","down",enableEdit) function BuildingStartEdit () if not isEnable then if oneTick then destroyElement(editObject) oneTick = false end return end tx, ty, tz = getWorldFromScreenPosition ( (sw / 2) - 3,(sh / 2) - 100, 15 ) px, py, pz = getCameraMatrix() if oneTick then local hit, faceX, faceY, faceZ, elementHit = processLineOfSight ( tx, ty, tz, px, py, pz,true ,true ,true ,true ,true ,false ,false ,false) BuildingEditCreate (faceX, faceY, faceZ) oneTick = false end local overGround = getGroundPosition(getElementPosition(editObject)) hit, faceX, faceY, faceZ, elementHit = processLineOfSight ( tx, ty, tz, px, py, pz,true ,false ,false ,false ,false ,false ,false ,false , editObject) if faceX == nil or faceY == nil then faceX = faceX or tx faceY = faceY or ty end xO,yO,yZ = getElementPosition(editObject) xC,yC = getElementPosition(localPlayer) if yZ < 1.5 then print("lower") setElementPosition(editObject,faceX, faceY, (overGround + 1) + levelVar) end setElementPosition(editObject,faceX, faceY, (overGround + 1) + levelVar) setElementRotation(editObject,0,0,findRotation(xO,yO,xC,yC) + currentIndex) --Debug dxDrawText('Object Position:',10,300) dxDrawText('X: '..xO,100,320) dxDrawText('Y: '..yO,100,340) dxDrawText('Z: '..yZ,100,360) end addEventHandler("onClientRender",root,function() BuildingStartEdit () end); bindKey("pgup","down",function() if levelVar > 1 then return end levelVar = levelVar + 0.10 end) bindKey("pgdn","down",function() if levelVar < 0 then return end levelVar = levelVar - 0.10 end) function increaseIndex() currentIndex = currentIndex + 10 end bindKey("mouse_wheel_up","down",increaseIndex) function decreseIndex() currentIndex = currentIndex - 10 end bindKey("mouse_wheel_down","down",decreseIndex) Link to comment
The_GTA Posted January 11, 2022 Share Posted January 11, 2022 Have you considered that the getGroundPosition function does return the highest z-coordinate below the coordinate that you pass to it? You could run into a problem, for instance, if your editObject's position is below all the GTA SA game collision. What do you mean about "working well", by the way? Am I wrong to assume that you are experiencing getGroundPosition returning false? Or are you dissatisfied about the quality of the function result? Link to comment
iwalidza Posted January 11, 2022 Author Share Posted January 11, 2022 26 minutes ago, The_GTA said: Have you considered that the getGroundPosition function does return the highest z-coordinate below the coordinate that you pass to it? You could run into a problem, for instance, if your editObject's position is below all the GTA SA game collision. What do you mean about "working well", by the way? Am I wrong to assume that you are experiencing getGroundPosition returning false? Or are you dissatisfied about the quality of the function result? getGroundPosition return 0 i wiki that mean '0 if the point you tried to test is outside the loaded world map' how i can fix it Link to comment
iwalidza Posted January 11, 2022 Author Share Posted January 11, 2022 1 hour ago, The_GTA said: Have you considered that the getGroundPosition function does return the highest z-coordinate below the coordinate that you pass to it? You could run into a problem, for instance, if your editObject's position is below all the GTA SA game collision. What do you mean about "working well", by the way? Am I wrong to assume that you are experiencing getGroundPosition returning false? Or are you dissatisfied about the quality of the function result? error: NaN Link to comment
The_GTA Posted January 12, 2022 Share Posted January 12, 2022 3 hours ago, iwalidza said: how i can fix it Move the world camera for a few frames until loaded, as explained by me above. Given the details you have provided, I unfortunately cannot help you with that NaN inquiry. It sounds very unordinary. Link to comment
iwalidza Posted February 5, 2022 Author Share Posted February 5, 2022 On 12/01/2022 at 02:06, The_GTA said: Move the world camera for a few frames until loaded, as explained by me above. Given the details you have provided, I unfortunately cannot help you with that NaN inquiry. It sounds very unordinary. how i can get ground position with this in server side 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