Hello,
I’m trying to get an entity (in this case a vehicle) bone’s local coordinates / vector, relative to the entity.
It’s easier to explain it with a picture:
I am not good at math, did anyone solve a similar issue?
HifziRS
September 28, 2020, 6:15am
2
local vectorTarget= GetWorldPositionOfEntityBone(vehicle, GetEntityBoneIndexByName(vehicle, 'wheel_lr'))
if you need vector coords other bone
1 Like
Thank you very much for your answer; however I’m trying to find the relative coordinates, while that native returns me the global coordinates
Could anyone help me, the rim moves when the vehicle’s rotation changes, I want to always keep it below the steering wheel
CreateThread(function()
while true do
local Ped = PlayerPedId()
local TimeDistance = IsPedInAnyVehicle(Ped) and 0 or 999
if TimeDistance == 0 then
local vehicle = GetVehiclePedIsUsing(Ped)
local minDim, maxDim = GetModelDimensions(GetEntityModel(vehicle))
local forwardVector, rightVector, upVector, position = GetEntityMatrix(vehicle)
local groundOffset = vec3(minDim.x * rightVector.x, minDim.x * rightVector.y, minDim.x * rightVector.z + minDim.z * upVector.z)
local groundPosition = position + groundOffset
local wheelCenter = GetWorldPositionOfEntityBone(vehicle, GetEntityBoneIndexByName(vehicle, "wheel_lf")) -- cordenada da roda
local centerX, centerY, centerZ = position.x, position.y, position.z
local newX, newY, newZ = wheelCenter.x, wheelCenter.y, wheelCenter.z
local displacementX = (newX - centerX)
local displacementY = (newY - centerY)
local displacementZ = (newZ - centerZ)
DrawText3D(vec3(position.x + displacementX, position.y + displacementY, position.z + displacementZ), "Wheel")
DrawText3D(vec3(position.x + deslocamentoX, position.y + deslocamentoY, position.z + minDim.z), "Edge")
end
Wait(TimeDistance)
end
end)