Jump to content

Attached element server side world rotation bug ( ? )


Recommended Posts

Hi.

UPD.Ok, i solved this with Matrix and Vector.

Reaction was nil, so i dont know is this issue bug or not.

I found that getElementRotation () of attached object gives right values clientside and wrong server side. Is it known bug or no?

Script does:

1. Create vehicle

2. Create object

3. Attach object to vehicle with rotOffsetZ

4. Re attach object with different rotOffsetZ

5. Try to getElementRotation () of object client side - it gives correct value

6 Try to getElementRotation () of object server side - it gives wrong value

Client side script:

local _vehicle = nil 
local _object = nil 
  
  
  
local function checkRotation () 
     
    outputChatBox ( "--" ) 
    outputChatBox ( "--" ) 
    outputChatBox ( "--" ) 
     
    local objectRotX, objectRotY, objectRotZ = getElementRotation ( _object ) 
    outputChatBox ( "World rotation: objectRotX = " .. objectRotX .. ", objectRotY = " .. objectRotY .. ", objectRotZ = " .. objectRotZ ) 
     
    local posOffsetX, posOffsetY, posOffsetZ, rotOffsetX, rotOffsetY, rotOffsetZ = getElementAttachedOffsets ( _object)  
    outputChatBox ( "Rotation offset: rotOffsetX = " .. rotOffsetX .. ", rotOffsetY = " .. rotOffsetY .. ", rotOffsetZ = " .. rotOffsetZ ) 
     
    rotOffsetZ = rotOffsetZ + 1  
    outputChatBox ( "New rotation offset Z " .. rotOffsetZ ) 
     
    -- Variant 1     
    outputChatBox ( "Variant 1" ) 
    setElementAttachedOffsets ( _object, posOffsetX, posOffsetY, posOffsetZ, 0, 0, rotOffsetZ ) 
    -- Get attached object world rotation 
    objectRotX, objectRotY, objectRotZ = getElementRotation ( _object ) 
    outputChatBox ( "World rotation: objectRotX = " .. objectRotX .. ", objectRotY = " .. objectRotY .. ", objectRotZ = " .. objectRotZ ) 
     
    -- Variant 2 
    outputChatBox ( "Variant 2" ) 
    detachElements ( _object ) 
    attachElements ( _object, _vehicle, 0, 0, 3, 0, 0, rotOffsetZ ) 
    -- Get attached object world rotation 
    objectRotX, objectRotY, objectRotZ = getElementRotation ( _object ) 
    outputChatBox ( "World rotation: objectRotX = " .. objectRotX .. ", objectRotY = " .. objectRotY .. ", objectRotZ = " .. objectRotZ ) 
     
    -- Variant 3 
    outputChatBox ( "Variant 2" ) 
    -- Try "touch" vehicle rotation, maybe it will update object rotaion 
    local vehRotX, vehRotY, vehRotZ = getElementRotation ( _vehicle ) 
    setElementRotation ( _vehicle, vehRotX + 0.1, vehRotY + 0.1, vehRotZ + 0.1 ) 
    -- Get attached object world rotation 
    objectRotX, objectRotY, objectRotZ = getElementRotation ( _object ) 
    outputChatBox ( "World rotation: objectRotX = " .. objectRotX .. ", objectRotY = " .. objectRotY .. ", objectRotZ = " .. objectRotZ ) 
end 
  
  
  
  
local function init () 
  
    local x, y, z = getElementPosition ( localPlayer ) 
    setCameraTarget ( localPlayer ) 
     
    _vehicle = createVehicle ( 560, x, y + 5, z + 3 ) 
    setElementRotation ( _vehicle, 0, 0, 0 ) 
    _object = createObject ( 1337, x, y + 7, z + 5 ) 
    setElementRotation ( _object, 0, 0, 0 ) 
     
    attachElements ( _object, _vehicle, 0, 0, 3, 0, 0, 90 ) 
     
    setTimer ( checkRotation, 3000, 0 ) 
end 
  
  
  
  
  
local function HonClientResourceStart () 
    setTimer ( init, 4000, 1 )   
end 
addEventHandler ( 'onClientResourceStart', resourceRoot, HonClientResourceStart, false ) 

Client side return values:

[2016-04-13 13:02:34] [Output] : --

[2016-04-13 13:02:34] [Output] : --

[2016-04-13 13:02:34] [Output] : --

[2016-04-13 13:02:34] [Output] : World rotation: objectRotX = 0.15530395507813, objectRotY = 0.321533203125, objectRotZ = 89.977081298828

[2016-04-13 13:02:34] [Output] : Rotation offset: rotOffsetX = 0, rotOffsetY = 0, rotOffsetZ = 90

[2016-04-13 13:02:34] [Output] : New rotation offset Z 91

[2016-04-13 13:02:34] [Output] : Variant 1

[2016-04-13 13:02:34] [Output] : World rotation: objectRotX = 0.15530395507813, objectRotY = 0.321533203125, objectRotZ = 89.977081298828

[2016-04-13 13:02:34] [Output] : Variant 2

[2016-04-13 13:02:34] [Output] : World rotation: objectRotX = 0.160888671875, objectRotY = 0.31878662109375, objectRotZ = 90.977081298828

[2016-04-13 13:02:34] [Output] : Variant 2

[2016-04-13 13:02:34] [Output] : World rotation: objectRotX = 0.160888671875, objectRotY = 0.31878662109375, objectRotZ = 90.977081298828

[2016-04-13 13:02:37] [Output] : --

[2016-04-13 13:02:37] [Output] : --

[2016-04-13 13:02:37] [Output] : --

[2016-04-13 13:02:37] [Output] : World rotation: objectRotX = 0.25909423828125, objectRotY = 0.21701049804688, objectRotZ = 91.077178955078

[2016-04-13 13:02:37] [Output] : Rotation offset: rotOffsetX = 0, rotOffsetY = 0, rotOffsetZ = 91

[2016-04-13 13:02:37] [Output] : New rotation offset Z 92

[2016-04-13 13:02:37] [Output] : Variant 1

[2016-04-13 13:02:37] [Output] : World rotation: objectRotX = 0.25909423828125, objectRotY = 0.21701049804688, objectRotZ = 91.077178955078

[2016-04-13 13:02:37] [Output] : Variant 2

[2016-04-13 13:02:37] [Output] : World rotation: objectRotX = 0.26284790039063, objectRotY = 0.21246337890625, objectRotZ = 92.077178955078

[2016-04-13 13:02:37] [Output] : Variant 2

[2016-04-13 13:02:37] [Output] : World rotation: objectRotX = 0.26284790039063, objectRotY = 0.21246337890625, objectRotZ = 92.077178955078

[2016-04-13 13:02:40] [Output] : --

[2016-04-13 13:02:40] [Output] : --

[2016-04-13 13:02:40] [Output] : --

[2016-04-13 13:02:40] [Output] : World rotation: objectRotX = 0.3592529296875, objectRotY = 0.10906982421875, objectRotZ = 92.176849365234

[2016-04-13 13:02:40] [Output] : Rotation offset: rotOffsetX = 0, rotOffsetY = 0, rotOffsetZ = 92

[2016-04-13 13:02:40] [Output] : New rotation offset Z 93

[2016-04-13 13:02:40] [Output] : Variant 1

[2016-04-13 13:02:40] [Output] : World rotation: objectRotX = 0.3592529296875, objectRotY = 0.10906982421875, objectRotZ = 92.176849365234

[2016-04-13 13:02:40] [Output] : Variant 2

[2016-04-13 13:02:40] [Output] : World rotation: objectRotX = 0.36111450195313, objectRotY = 0.102783203125, objectRotZ = 93.176849365234

[2016-04-13 13:02:40] [Output] : Variant 2

[2016-04-13 13:02:40] [Output] : World rotation: objectRotX = 0.36111450195313, objectRotY = 0.102783203125, objectRotZ = 93.176849365234

[2016-04-13 13:02:43] [Output] : --

[2016-04-13 13:02:43] [Output] : --

[2016-04-13 13:02:43] [Output] : --

[2016-04-13 13:02:43] [Output] : World rotation: objectRotX = 0.4556884765625, objectRotY = 359.99771118164, objectRotZ = 93.276214599609

[2016-04-13 13:02:43] [Output] : Rotation offset: rotOffsetX = 0, rotOffsetY = 0, rotOffsetZ = 93

[2016-04-13 13:02:43] [Output] : New rotation offset Z 94

[2016-04-13 13:02:43] [Output] : Variant 1

[2016-04-13 13:02:43] [Output] : World rotation: objectRotX = 0.4556884765625, objectRotY = 359.99771118164, objectRotZ = 93.276214599609

[2016-04-13 13:02:43] [Output] : Variant 2

[2016-04-13 13:02:43] [Output] : World rotation: objectRotX = 0.45556640625, objectRotY = 359.98974609375, objectRotZ = 94.276184082031

[2016-04-13 13:02:43] [Output] : Variant 2

[2016-04-13 13:02:43] [Output] : World rotation: objectRotX = 0.45556640625, objectRotY = 359.98974609375, objectRotZ = 94.276184082031

[2016-04-13 13:02:46] [Output] : --

[2016-04-13 13:02:46] [Output] : --

[2016-04-13 13:02:46] [Output] : --

[2016-04-13 13:02:46] [Output] : World rotation: objectRotX = 0.54840087890625, objectRotY = 359.88305664063, objectRotZ = 94.375183105469

[2016-04-13 13:02:46] [Output] : Rotation offset: rotOffsetX = 0, rotOffsetY = 0, rotOffsetZ = 94

[2016-04-13 13:02:46] [Output] : New rotation offset Z 95

[2016-04-13 13:02:46] [Output] : Variant 1

[2016-04-13 13:02:46] [Output] : World rotation: objectRotX = 0.54840087890625, objectRotY = 359.88305664063, objectRotZ = 94.375183105469

[2016-04-13 13:02:46] [Output] : Variant 2

[2016-04-13 13:02:46] [Output] : World rotation: objectRotX = 0.5462646484375, objectRotY = 359.87350463867, objectRotZ = 95.375122070313

[2016-04-13 13:02:46] [Output] : Variant 2

[2016-04-13 13:02:46] [Output] : World rotation: objectRotX = 0.5462646484375, objectRotY = 359.87350463867, objectRotZ = 95.375122070313

As you see, objectRotZ always corret and depends on rotation offset Z of attached object.

Server side:

local _vehicle = nil 
local _object = nil 
  
  
  
local function checkRotation () 
     
    outputChatBox ( "--Server" ) 
    outputChatBox ( "--Server" ) 
    outputChatBox ( "--Server" ) 
     
    local objectRotX, objectRotY, objectRotZ = getElementRotation ( _object ) 
    outputChatBox ( "World rotation: objectRotX = " .. objectRotX .. ", objectRotY = " .. objectRotY .. ", objectRotZ = " .. objectRotZ ) 
     
    local posOffsetX, posOffsetY, posOffsetZ, rotOffsetX, rotOffsetY, rotOffsetZ = getElementAttachedOffsets ( _object)  
    outputChatBox ( "Rotation offset: rotOffsetX = " .. rotOffsetX .. ", rotOffsetY = " .. rotOffsetY .. ", rotOffsetZ = " .. rotOffsetZ ) 
     
    rotOffsetZ = rotOffsetZ + 1  
    outputChatBox ( "New rotation offset Z " .. rotOffsetZ ) 
     
    -- Variant 1     
    outputChatBox ( "Variant 1" ) 
    setElementAttachedOffsets ( _object, posOffsetX, posOffsetY, posOffsetZ, 0, 0, rotOffsetZ ) 
    -- Get attached object world rotation 
    objectRotX, objectRotY, objectRotZ = getElementRotation ( _object ) 
    outputChatBox ( "World rotation: objectRotX = " .. objectRotX .. ", objectRotY = " .. objectRotY .. ", objectRotZ = " .. objectRotZ ) 
     
    -- Variant 2 
    outputChatBox ( "Variant 2" ) 
    detachElements ( _object ) 
    attachElements ( _object, _vehicle, 0, 0, 3, 0, 0, rotOffsetZ ) 
    -- Get attached object world rotation 
    objectRotX, objectRotY, objectRotZ = getElementRotation ( _object ) 
    outputChatBox ( "World rotation: objectRotX = " .. objectRotX .. ", objectRotY = " .. objectRotY .. ", objectRotZ = " .. objectRotZ ) 
     
    -- Variant 3 
    outputChatBox ( "Variant 2" ) 
    -- Try "touch" vehicle rotation, maybe it will update object rotaion 
    local vehRotX, vehRotY, vehRotZ = getElementRotation ( _vehicle ) 
    setElementRotation ( _vehicle, vehRotX + 0.1, vehRotY + 0.1, vehRotZ + 0.1 ) 
    -- Get attached object world rotation 
    objectRotX, objectRotY, objectRotZ = getElementRotation ( _object ) 
    outputChatBox ( "World rotation: objectRotX = " .. objectRotX .. ", objectRotY = " .. objectRotY .. ", objectRotZ = " .. objectRotZ ) 
end 
  
  
  
local function init () 
     
    local player = getRandomPlayer () 
     
    if ( not player ) then 
        return 
    end 
  
    spawnPlayer ( player, 0, 0, 10 ) 
    setCameraTarget ( player ) 
     
    _vehicle = createVehicle ( 560, 0, 5, 50 ) 
    setElementRotation ( _vehicle, 0, 0, 0 ) 
    _object = createObject ( 1337, 0, 6, 7 ) 
    setElementRotation ( _object, 0, 0, 0 ) 
  
    attachElements ( _object, _vehicle, 0, 0, 3, 0, 0, 90 )  
     
    setTimer ( checkRotation, 3000, 0 ) 
end 
  
  
  
  
  
local function HonResourceStart ()   
    setTimer ( init, 4000, 1 ) 
end 
addEventHandler ( "onResourceStart", resourceRoot, HonResourceStart ) 

Server side return values:

[2016-04-13 13:11:19] [Output] : --Server

[2016-04-13 13:11:19] [Output] : --Server

[2016-04-13 13:11:19] [Output] : --Server

[2016-04-13 13:11:19] [Output] : World rotation: objectRotX = 0.3790283203125, objectRotY = 0.0054931640625, objectRotZ = 116.6201171875

[2016-04-13 13:11:19] [Output] : Rotation offset: rotOffsetX = 0, rotOffsetY = 0, rotOffsetZ = 90

[2016-04-13 13:11:19] [Output] : New rotation offset Z 91

[2016-04-13 13:11:19] [Output] : Variant 1

[2016-04-13 13:11:19] [Output] : World rotation: objectRotX = 0.3790283203125, objectRotY = 0.0054931640625, objectRotZ = 173.916015625

[2016-04-13 13:11:19] [Output] : Variant 2

[2016-04-13 13:11:19] [Output] : World rotation: objectRotX = 0.3790283203125, objectRotY = 0.0054931640625, objectRotZ = 173.916015625

[2016-04-13 13:11:19] [Output] : Variant 2

[2016-04-13 13:11:19] [Output] : World rotation: objectRotX = 0.47900390625, objectRotY = 0.10549926757813, objectRotZ = 174.01611328125

[2016-04-13 13:11:22] [Output] : --Server

[2016-04-13 13:11:22] [Output] : --Server

[2016-04-13 13:11:22] [Output] : --Server

[2016-04-13 13:11:22] [Output] : World rotation: objectRotX = 0.47900390625, objectRotY = 0.10549926757813, objectRotZ = 174.01611328125

[2016-04-13 13:11:22] [Output] : Rotation offset: rotOffsetX = 0, rotOffsetY = 0, rotOffsetZ = 91

[2016-04-13 13:11:22] [Output] : New rotation offset Z 92

[2016-04-13 13:11:22] [Output] : Variant 1

[2016-04-13 13:11:22] [Output] : World rotation: objectRotX = 0.47900390625, objectRotY = 0.10549926757813, objectRotZ = 231.3115234375

[2016-04-13 13:11:22] [Output] : Variant 2

[2016-04-13 13:11:22] [Output] : World rotation: objectRotX = 0.47900390625, objectRotY = 0.10549926757813, objectRotZ = 231.3115234375

[2016-04-13 13:11:22] [Output] : Variant 2

[2016-04-13 13:11:22] [Output] : World rotation: objectRotX = 0.57904052734375, objectRotY = 0.20550537109375, objectRotZ = 231.41162109375

[2016-04-13 13:11:25] [Output] : --Server

[2016-04-13 13:11:25] [Output] : --Server

[2016-04-13 13:11:25] [Output] : --Server

[2016-04-13 13:11:25] [Output] : World rotation: objectRotX = 0.5767822265625, objectRotY = 0.2032470703125, objectRotZ = 231.4091796875

[2016-04-13 13:11:25] [Output] : Rotation offset: rotOffsetX = 0, rotOffsetY = 0, rotOffsetZ = 92

[2016-04-13 13:11:25] [Output] : New rotation offset Z 93

[2016-04-13 13:11:25] [Output] : Variant 1

[2016-04-13 13:11:25] [Output] : World rotation: objectRotX = 0.5767822265625, objectRotY = 0.2032470703125, objectRotZ = 288.705078125

[2016-04-13 13:11:25] [Output] : Variant 2

[2016-04-13 13:11:25] [Output] : World rotation: objectRotX = 0.5767822265625, objectRotY = 0.2032470703125, objectRotZ = 288.705078125

[2016-04-13 13:11:25] [Output] : Variant 2

[2016-04-13 13:11:25] [Output] : World rotation: objectRotX = 0.67678833007813, objectRotY = 0.30325317382813, objectRotZ = 288.80517578125

[2016-04-13 13:11:28] [Output] : --Server

[2016-04-13 13:11:28] [Output] : --Server

[2016-04-13 13:11:28] [Output] : --Server

[2016-04-13 13:11:28] [Output] : World rotation: objectRotX = 0.67678833007813, objectRotY = 0.30325317382813, objectRotZ = 288.80517578125

[2016-04-13 13:11:28] [Output] : Rotation offset: rotOffsetX = 0, rotOffsetY = 0, rotOffsetZ = 93

[2016-04-13 13:11:28] [Output] : New rotation offset Z 94

[2016-04-13 13:11:28] [Output] : Variant 1

[2016-04-13 13:11:28] [Output] : World rotation: objectRotX = 0.67678833007813, objectRotY = 0.30325317382813, objectRotZ = 346.10107421875

[2016-04-13 13:11:28] [Output] : Variant 2

[2016-04-13 13:11:28] [Output] : World rotation: objectRotX = 0.67678833007813, objectRotY = 0.30325317382813, objectRotZ = 346.10107421875

[2016-04-13 13:11:28] [Output] : Variant 2

[2016-04-13 13:11:28] [Output] : World rotation: objectRotX = 0.77679443359375, objectRotY = 0.40325927734375, objectRotZ = 346.201171875

Same objectRotZ returns everytime incorrect value ( 173.916015625, 231.3115234375, 288.705078125, 346.10107421875 ) even if attached object's rotation Z offset is changed to 1 angle.

Edited by Guest
Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...