bradio10 Posted April 5, 2015 Share Posted April 5, 2015 Hi, So I've been mucking around with moveObject and trying to rotate doors and the police barrier. Now, I have noticed something strange and I can't seem to get my head around it. When I create the barrier, I set it to create with a rotation of 90, 0, 90. When I enter the marker, it moves to point the sky (like I want it to), but when I output what the rotation of it is when its pointing to the sky, it still says 90, 0, 90. When I exit the marker, it moves back to the rotation it was created with, but it says its 0, 0, 90. So I tried to create the object starting at 0, 0, 90 (cus it says that its 0, 0, 90 when it comes back down), but it then creates itself pointing to the sky. I'm pretty sure its something that I am not understanding when it says: the rotation along the X axis relative to its current rotation, which is its starting angle. (from the wiki on moveObject), but I dont understand what this actually means. The reason why I am wanting to know all this is because I noticed that when to you go into the marker, if you exit quick enough while its around half way up, it then comes back down but it goes to the wrong angle. So I am trying to make it so I can check to see if the angle if the wrong angle, it'll fix itself and go back to normal. If there is an easier way to do this, then please let me know. Here is the code: x1, y1, z1 = -721.30396, 945.42999, 12.13281 rotx, roty, rotz = 0, 0, 90 x, y, z = -720.60193, 967.94867, 11.13281 rotx1, roty1, rotz1 = -90, 0, 0 marker1 = createMarker(x1 + 3, y1, z1 - 1, "cylinder", 5, 255, 255, 0, 100) marker2 = createMarker(x, y, z, "cylinder", 5, 255, 255, 0, 100) object1 = createObject(2920, x1, y1, z1, 90, 0, 90) object2 = createObject(2948, x, y, z, 0, 0, 0) addEventHandler("onMarkerHit", marker2, function() --setTimer( function() moveObject(object2, 1000, x, y, z, rotx, roty, rotz) --end --, 200, 1) end ) addEventHandler("onMarkerLeave", marker2, function() --setTimer( function() moveObject(object2, 1000, x, y, z, 0, 0, -90) --end --, 1100, 1) end ) addEventHandler("onMarkerHit", marker1, function() --setTimer( function() --setElementData(object1, "opening", false) --cRotX, cRotY, cRotZ = getElementRotation(object1) --if () if (getElementData(object1, "opening") == false and getElementData(object1, "closing") == false) then setElementData(object1, "opening", true) outputChatBox(tostring(getElementData(object1, "opening")), root) moveObject(object1, 500, x1, y1, z1, rotx1, roty1, rotz1) setTimer( function() setElementData(object1, "opening", false) outputChatBox(tostring(getElementData(object1, "opening")), root) end, 500, 1) end --setElementData(object1, "opening", false) --end --, 200, 1) end ) addEventHandler("onMarkerLeave", marker1, function() --setTimer( function() if (getElementData(object1, "closing") == false and getElementData(object1, "opening") == false) then setElementData(object1, "closing", true) outputChatBox(tostring(getElementData(object1, "closing")), root) moveObject(object1, 500, x1, y1, z1, 90, 0, 0) setTimer( function() setElementData(object1, "closing", false) outputChatBox(tostring(getElementData(object1, "closing")), root) end, 500, 1) end --end --, 1100, 1) end ) addCommandHandler("getdata", function() local cRotX1, cRotY1, cRotZ1 = getElementRotation(object1) local cRotX2, cRotY2, cRotZ2 = getElementRotation(object2) outputChatBox("Closing: " .. tostring(getElementData(object1, "closing")), root) outputChatBox("Opening: " .. tostring(getElementData(object1, "opening")), root) outputChatBox("Object1 rot = x: " .. tostring(cRotX1) .. ", y: " .. tostring(cRotY1) .. ", z: " .. tostring(cRotZ1), root) outputChatBox("Object2 rot = x: " .. tostring(cRotX2) .. ", y: " .. tostring(cRotY2) .. ", z: " .. tostring(cRotZ2), root) end ) It's abit messy and I understand if my description that I wrote above doesnt make sense to some, so if thats the case, I am happy to make a video and post it on youtube to better describe my problem. (The element data stuff was my way of trying to get it so if you exit quick enough, it wont glitch the angle, but after awhile, it still does it) PS: I also tried it with the door which is object2 and it has the same thing happen to it. Thanks! 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