Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EDF custom vehicle rotation doesn't match actual vehicle rotation #150

Open
javier2409 opened this issue Jun 3, 2019 · 2 comments
Open

Comments

@javier2409
Copy link

javier2409 commented Jun 3, 2019

Which resource(s) have this problem?
Not sure, edf, editor_main maybe

Describe the bug
The rotation of a custom element represented by a vehicle seems to work differently than the rotation of an actual vehicle.
For example, if I want to use that custom element's rotation to do something with real vehicles, It won't work as expected.
This doesn't happen with all rotations.

To Reproduce

  1. Define a custom element that is represented by a vehicle, for example:
	<element name="customveh" friendlyname="Custom vehicle">
		<vehicle editorOnly="true" model="!model!" />
		<data name="model" type="vehicleID" default="411" />
		<data name="position" type="coord3d" default="0,0,0" />
		<data name="rotation" type="coord3d" default="0,0,0" />
	</element>
  1. Place one in a map
  2. Set it's rotation to x:345 y:180 z:90
  3. Save the map and play it
  4. Create a vehicle through scripting and set it's rotation to the same as the custom element in the map file -> Rotations do not match

Expected behavior
If I create a custom element represented by a vehicle it's rotation should match an actual vehicle rotation.

Screenshots
See 'additional context'

Version
1.5.6

Additional context
I made a forum post regarding this problem
https://forum.mtasa.com/topic/117044-possible-editor-bug/

@javier2409
Copy link
Author

Found workaround
You need to convert 'object' rotation in ZXY format to 'vehicle' rotation in ZYX format.

But I think the editor should give the rotation in ZYX format if the element is represented as a Vehicle

@FileEX
Copy link
Contributor

FileEX commented Jun 9, 2019

I don't sure if this is solution so i don't do pull request yet. Please check this:

  1. Open edf_client.lua file ([edito]/edf/)
  2. Find this function
function edfSetElementRotation(element, rx, ry, rz)
	if rx and ry and rz then
		local etype = getElementType(element)
		if etype == "object" or etype == "vehicle" or etype == "player" or etype == "ped" then
			return setElementRotation(element, rx, ry, rz)
		else
			local handle = edfGetHandle(element)
			if handle then
				return setElementRotation(handle, rx, ry, rz)
			else
				setElementData(element, "rotX", rx or 0)
				setElementData(element, "rotY", ry or 0)
				setElementData(element, "rotZ", rz or 0)
				return true
			end
		end
	end
end
  1. Change this line
if etype == "object" or etype == "vehicle" or etype == "player" or etype == "ped" then
			return setElementRotation(element, rx, ry, rz) -- THIS
		else

to

if etype == "object" or etype == "vehicle" or etype == "player" or etype == "ped" then
			return setElementRotation(element, rx, ry, rz, etype == 'vehicle' and 'ZYX' or 'default') -- THIS
		else
  1. Test it and tell me if it fix that issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants