I’m experiencing some issues with CreateObject and CreateObjectNoOffset. My map loader parses an .xml file saved by the MapEditor mod. I have verified over and over that tables are populated correctly and with the correct values. I double check them when they’re transferred to the client.
Using either Trace (trace for whatever reasons ouputs twice to the console, am I misusing it or is this a bug?). I confirm that I get the right amount of entities - in this case, 7 props and 24 vehicles. I’ve also compared their hash, position, rotation and quaternion to the XML file several times.
Also, for some reason there is always 1 object that will remain if I stop the resource. Here’s a video of what is going on;
https://streamable.com/gqnfx
And here’s a screenshot of what it should look like;
This is the code I use to create the objects (I have tried both with and without using an asynchronous thread);
for i=1, #propList do
--[[ {Hash, {PosX, PosY, PosZ}, {RotX, RotY, RotZ}, {QuatX, QuatY, QuatZ, QuatW}, Dynamic} ]]
--[[ {Hash, {PosX, PosY, PosZ}, {RotX, RotY, RotZ}, Dynamic} ]]
-- If index 4 is a table, that means it has a quaternion shitty headache thing
if(type(propList[i][4]) == "table") then
local theObject = CreateObjectNoOffset(propList[i][1], propList[i][2][1], propList[i][2][2], propList[i][2][3], false, false, false)
if(theObject) then
SetEntityCoords(theObject, propList[i][2][1], propList[i][2][2], propList[i][2][3])
SetEntityRotation(theObject, propList[i][3][1], propList[i][3][2], propList[i][3][3], 2, true)
SetEntityQuaternion(theObject, propList[i][4][1], propList[i][4][2], propList[i][4][3], propList[i][4][4])
FreezeEntityPosition(theObject, true)
table.insert(spawnedProps, theObject)
end
elseif(propList[i][4] == "true" or propList[i][4] == "false") then
local theObject = CreateObjectNoOffset(propList[i][1], propList[i][2][1], propList[i][2][2], propList[i][2][3], false, false, false)
if(theObject) then
SetEntityCoords(theObject, propList[i][2][1], propList[i][2][2], propList[i][2][3])
SetEntityRotation(theObject, propList[i][3][1], propList[i][3][2], propList[i][3][3], 2, true)
FreezeEntityPosition(theObject, true)
table.insert(spawnedProps, theObject)
end
end
end
At this point I’m all out of ideas, I’ve fiddled with collisions, the last 2 parameters in SetEntityRotation. I’ve tried ignoring quaternions completely. I’ve tried changing the values in the XML file to be floats (for pos, rot and quat).
My hair has now turned all grey and is starting to fall off, so I’m gonna hit the bed. If anyone has any suggestions or advice, please let me know.