Category | Scripting |
Created | 24.08.2021 08:49 |
@ Squity (Squity) | 24.08.2021 08:49 |
---|---|
Hi, i need some help with attachments. So i know how to get attached implements with vehicle:getAttachedImplements(). But how do i know if is a front or a back attachment? Also in case of multiple back attachments, how do you know which is the first and second one? |
Bilbo Beutlin (BBeutlin) | 24.08.2021 15:28 |
---|---|
An easy way is 'localDirectionToLocal()' to get the orientation of a node relative to another. For reference see LUADOC/Engine/Scenegraph/localDirectionToLocal. You'll also find many examples for usage in the Giants Remote Debugger sources. |
@ Squity (Squity) | 29.08.2021 08:19 |
---|---|
Thank you B. It's a bit difficult and intensive way to retrieve such info but i will give it a try, i was hopping for a property in vehicle object. |
@ Squity (Squity) | 08.03.2022 17:56 |
---|---|
Hi again. I did implemented a way to detect if is front or back attached implement but does not always work, it feels bugged, in a normal case when you attach first the back implement and then the front one always work, but then if i dettach the back one in some cases will return an unexpected value, the X will contain a negative value. This is my implementation based on your proposal BB. local dirX, dirY, _ = localDirectionToLocal(currentVehicle.components[1].node, implement.components[1].node, 0, 0, 1) if dirX > 0 then -- THIS IS BACK IMPLEMENT. else -- THIS IS FRONT IMPLEMENT. end Do you guys have any idea if i'm doing something work, way i'm getting such results from the game? Thanks. |
Martin Eller (Jason0611) | 10.03.2022 14:14 |
---|---|
Hi, I've resolved it like following and it works well: First you have to find out the jointDescIndex of the joint the implement (currentImplement) was connected to: for _,impl in pairs(currentVehicle.spec_attacherJoints.attachedImplements) do if impl.object == currentImplement then jointDescIndex = impl.jointDescIndex break end end Then you can check if it was in front or back: local jointDesc = currentVehicle.spec_attacherJoints.attacherJoints[jointDescIndex] local wx, wy, wz = getWorldTranslation(jointDesc.jointTransform) local lx, ly, lz = worldToLocal(currentVehicle.steeringAxleNode, wx, wy, wz) if lz > 0 then frontImpl = true print("Front implement") else backImpl = true print("Back implement") end |
@ Squity (Squity) | 10.03.2022 19:23 |
---|---|
Thank you so much Martin. It works for now, i hope it will work for all possible cases. I've also find another way that i think is used by the game to show the little icons on top left side of the screen, the ones that displays the list of implements and vehicle. This is the code: local jointDesc = currentVehicle.schemaOverlay.attacherJoints[implementRoot.jointDescIndex]; local isFrontImplement = jointDesc and jointDesc.invertX or false; But i'm still not sure which method is better, the invertX may not work fine on mods if the joinDesc is badly designed. |
Note: Log in to post. Create a new account here.