Jump to content

Possible editor bug?


-Gus-

Recommended Posts

Hello everyone. I wasn't sure If I should post this here because it may not be 100% related to scripting, but I ran into this problem by making a script, so here it goes.

I'm making a script that uses custom elements defined in an EDF file, and relies heavily on the rotation of those elements because it uses the "forward" vector of their matrices. The problem is that the rotation that the editor gives is somehow bugged, let me show you this with an example:

Let's say I place one of my custom elements, which is represented within the editor with a vehicle, and set it's rotation to X=345, Y=180, Z=90. I get this:

120o8lz.jpg

Now if I do the same with a normal vehicle, and set the exact same rotation I get this:

2lsi3br.jpg

Now if I click "OK" and then open the vehicle properties again, the rotation is changed! (this does not happen with my custom element, that one stays with the rotation I set)

2pzch8k.jpg

The problem is that if I calculate the "forward" vector for my custom element, what I get is what I would get if the rotation was the second one (in this example X=165, Y=0, Z=270), but that is not the rotation that the editor is showing me (neither visually or in the properties). And even worse: The rotation that I used as an example is the one I get if I rotate the element using the keyboard, I can manually set a different rotation (that gives the same visually) that works fine, but for UX reasons I can't tell my script's users to do that if they run into this bug.

Here is the code that does the "forward vector" thing:

saves[cshape]['pos'] = Vector3(autojumpEnd:getData('posX')),autojumpEnd:getData('posY')),autojumpEnd:getData('posZ')))
saves[cshape]['rot'] = Vector3(autojumpEnd:getData('rotX'),autojumpEnd:getData('rotY'),autojumpEnd:getData('rotZ'))
saves[cshape]['vel'] = Matrix(saves[cshape]['pos'],saves[cshape]['rot']):getForward() * tonumber(autojump:getData('speed'))

So my question is: Is this an editor bug? Is it something I'm doing wrong? How can I work this out? Any help is appreciated.

Link to comment

I found the solution, it seems that the map editor treats custom elements as objects (even if they are represented as vehicles or whatever) and rotations are different between objects and vehicles, so you need to convert the rotation from 'object format' to 'vehicle format'. One way to do that is creating a dummy object and setting its rotation to your custom element rotation, and then do getElementRotation(dummyObject, 'ZYX') to get the same rotation in 'vehicle format' (it's called ZYX format actually, and ZXY is for objects in case you wanna know)

  • Like 1
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...