Jump to content

rotation editor vs rotation script trouble


Faw[Ful]

Recommended Posts

Hi there ! When I rotate my object in the editor with page up page down it rotate perfectly in this way :

33600437.jpg

I use page up and page down bind key, it rotate on the x axis im not sure and I cant find it

The object have been rotate on the z axis and rotate a little with the bind keys ctrl + up and ctrl + down

but when I script a rotation to make the object rotate continuously, it dont rotate correctly like I see in the editor, it rotate on x and y axis strangely. I use a classic animation script serverside like that :

function resource_starts() 
object1 = createObject ( 2383, 4044.234375, -961.06164550781,  
  
106.23023223877, 303.23327636719, 17.519775390625, 110.04156494141 ) 
object2 = createObject ( 2383, 4039.0607910156, -905.19128417969,  
  
97.080238342285, 281.21917724609, 122.01065063477, 217.759765625 ) 
object3 = createObject ( 2383, 4033.9145507813, -849.27093505859,  
  
87.430244445801, 9.854736328125, 9.635009765625, 93.58154296875 ) 
object4 = createObject ( 2383, 4028.7492675781, -793.34924316406,  
  
78.0302734375, 9.854736328125, 9.635009765625, 93.58154296875 ) 
object5 = createObject ( 2383, 4023.6062011719, -737.34436035156,  
  
68.630310058594, 9.854736328125, 9.635009765625, 93.58154296875 ) 
object6 = createObject ( 2383, 3545.416015625, -907.46282958984,  
  
92.082801818848, 0, 358.25, 18.5 ) 
object7 = createObject ( 2383, 3491.5483398438, -925.49310302734,  
  
90.35774230957, 0, 358.24768066406, 18.495483398438 ) 
object8 = createObject ( 2383, 3437.6062011719, -943.55346679688,  
  
88.607635498047, 0, 358.24768066406, 18.495483398438 ) 
end 
addEventHandler ( "onResourceStart", getRootElement(),  
  
resource_starts ) 
  
function move1_1() 
moveObject ( object1, 2000, 4044.234375, -961.06164550781,  
  
106.23023223877, 360, 0, 0 ) 
moveObject ( object2, 2000, 4039.0607910156, -905.19128417969,  
  
97.080238342285, 360, 0, 0 ) 
moveObject ( object3, 2000, 4033.9145507813, -849.27093505859,  
  
87.430244445801, 360, 0, 0 ) 
moveObject ( object4, 2000, 4028.7492675781, -793.34924316406,  
  
78.0302734375, 360, 0, 0 ) 
moveObject ( object5, 2000, 4023.6062011719, -737.34436035156,  
  
68.630310058594, 360, 0, 0 ) 
moveObject ( object6, 2000, 3545.416015625, -907.46282958984,  
  
92.082801818848, 360, 0, 0 ) 
moveObject ( object7, 2000, 3491.5483398438, -925.49310302734,  
  
90.35774230957, 360, 0, 0 ) 
moveObject ( object8, 2000, 3437.6062011719, -943.55346679688,  
  
88.607635498047, 360, 0, 0 ) 
end 
setTimer ( move1_1, 2000, 0 ) 
addEventHandler ( "onResourceStart", getRootElement(), move1_1 ) 
  

In the move object I set the same position so the object dont move and im to noob to know the empty value so I copy paste all the objects position, take a look at the rotation I set 360 only for the x axis to make it rotate like in the editor, dont work maybe is the y, no dont work, so the editor rotate in a different way, but wich ?

How to script a rotation like in the editor ?

I find this function in a script that make a object rotate continuously only on the z axis :

function()

setElementRotation(obj, 0, 0, (getTickCount() / 20) % 360)

end

)

Link to comment

That's because of euler rotation order.

Cf: viewtopic.php?p=326214#p326214

Objects in MTA are ZXY whereas vehicles are ZYX, meaning (for objects) rotation about world Z, then rotation about resulting X and then rotation about resulting Y (for objects). So the result is different depending on the order. Most people use moveObject to rotate about one axis at a time and on objects that have 0 rotation on X or Y so the problem is not seen for those.

The editor uses a patch, similar to the lua code you will find in the topic post above, to make objects rotate with ZYX and not ZXY.

It has now been integrated in MTA 1.1 directly via an extra parameter for https://wiki.multitheftauto.com/wiki/SetElementRotation which, as far as I know, hasn't been backported to 1.0.4.

However moveObject isn't affected by it yet, and I intend to fix that, hopefully it will be backported.

For now, if you do the moveObject clientside, you can work around the issue by doing the moveObject yourself onClientRender and using the lua patch above. If you do it serverside, you have to wait for it to be implemented and backported.

Edit: actually now that I think about how moveObject is done (since I'm already working on it for something else) I can tell you that even if it gets implemented, it will create some rotation artefacts on the non updated clients. I will implement it though, but I don't think this part should be backported.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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