-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Method to get relative object position (attachments) #14696
Comments
object:get_attach()? that will tell you the position given in :set_attach(). Maybe I misunderstood the issue, but we already can get the relative position of an object. It kind of sounds like you want the global position of an attached object? I'm not sure. But either way this is something that can be entirely implemented in lua with existing tools |
if you mean the position of the object in the global system relative to the object (so attached_pos-parent_pos) then you can just make a rotation matrix from the parent's rotation and multiply that by a 3x1 vector, then subtract the object position. https://www.symbolab.com/solver/matrix-multiply-calculator may help |
Yes, this can be implemented in Lua. Since there is no library doing this yet, modders are presently usually just using the incorrect The engine should provide this, especially since it needs this itself (if we are to make a better effort for raycasts). Related: #14231 contains code to calculate transformations along the attachment chain. |
Attached entities are considered by the server to be at the parent origin. However, the server knows the position and rotation of attachments and parents (aside from armature stuff), so it should be able to solve for child positions/rotation.
The solved relative position should be used for both an object method and raycasting (see #10304).
object:get_pos()
could natively return this relative position, though that could break some mods. Alternatively a new flag likeobject:get_pos(relative)
, or a new method likeobject:get_relative_pos()
.The text was updated successfully, but these errors were encountered: