AttachCamToEntity/PedBone Bug when Entity Position Updated?

I’m working on a freecam script and ran into a lot of trouble when trying to use AttachCamToEntity and AttachCamToPedBone.

It seems to always add 1.0 along the Z-axis, even if I update the ped’s location with vector3(0.0, 0.0, 0.0).

So I need to subtract 1.0 every time I update the ped’s position;

local newVector = GetEntityCoords(GetPlayerPed(-1))+newCamCoords
SetEntityCoords(GetPlayerPed(-1), newVector.x, newVector.y, newVector.z-1.0)

Not a huge bug, but it caused me a looot of headache.

Edit:

After some further testing, it seems like AttachCamToPedBone adds even more 1.0. Any idea what’s going on here?

I’ve managed to make it work by using AttachCamToEntity with relative bool set to true and always subtracting 1.0 from the Z-axis.

Maybe it’s like the SetEntityCoords() vs SetEntityCoordsNoOffset(), the first one adds some specific amount to the z to prevent entities from being accidentally teleported into the ground afaik.

Maybe there’s a NoOffset variant for your natives?

SetEntityCoords() is what I’m using, so I gave SetEntityCoordsNoOffset() one a try - but it yielded the same results. Still need to subtract 1.0.

To clarify, so long as I don’t have any offset set with AttachCamToEntity() and I use SetEntityCoordsNoOffset() - it works as intended.

If I add any offset or use AttachCamToPedBone() it starts applying weird offsets that not even SetEntityCoordsNoOffset() will prevent.