loki79uk / FS22_UniversalAutoload

Mod for FS22. Please download latest release below.
122 stars 35 forks source link

Add ability to increase or decrease the length of both the trigger area and the loading area simultaneously #219

Closed HatsuneKid closed 7 months ago

HatsuneKid commented 10 months ago

Hi, I want to adjust the front and rear starting positions of the loading area on a semi-trailer to optimize the mass position of the cargo in the game. And I did achieve it by using [ lengthAxis="xxx" ] & [ offsetRoot="xxx" ] Or rather, shorten the length of the loading area while moving the offset point of the loading area backward. But there is a problem. Now its operating logic is that the length of the loading area can only increase but not decrease, and the initial trigger area length is consistent with the loading area length and cannot be changed. I can use reverse animation to reduce the length of the loading area, but doing so will result in the initial trigger area being too short which is inconvenient for full length loading.

loki79uk commented 10 months ago

The reason I kept the triggers fixed was that I was worried it may not detect items entering/leaving the trigger during the resize process, I don't know how the engine detects collisions, and maybe it won't count if the trigger changes size. It may not be a problem, so I'll see if I can set up a test to prove it would work.

loki79uk commented 10 months ago

Did you make the negative 'spec_cylindered.movingTools' as a workaround, or is it likely to happen in other cases? Would it just work if I had a direction flag for the movement?

i.e. I could just add:

.loadingArea(?)#widthAxisDirection
.loadingArea(?)#lengthAxisDirection
.loadingArea(?)#heightAxisDirection

with the default as positive

HatsuneKid commented 10 months ago

Perhaps the trigger does not need to changed size. Adding a direction flag for the movement might work I think. Allowing the loading area to be reduced in size while keeping the initial size of the trigger is wonderful

HatsuneKid commented 10 months ago

I did make the negative 'spec_cylindered.movingTools' as a workaround. Cause I want to move the starting position of the loading area backwards while reducing its size. This seems to require a code to specify that I am controlling the front movement of the loading area.

loki79uk commented 10 months ago

Please try this one [removed link - see later post for updated version] I have not committed it yet, but the only change is to add three new flags for the loading areas: reverseWidthAxis="true" reverseLengthAxis="true" reverseHeightAxis="true"

edit: it is untested, but I think it will work, e.g.:

        local direction = loadArea.reverseLengthAxis and -1 or 1
        local extensionLength = math.abs(z) * direction
HatsuneKid commented 10 months ago

It work! And is there a better way to simply move the front of the loading area backward?

loki79uk commented 10 months ago

I'm not sure how you mean, do you want it to move with the control axis, or just to define an offset for the starting position?

edit: but good news that the reverse direction works!! :D

HatsuneKid commented 10 months ago

Yes I mean I want to move the front of the loading area backward with the control axis in game. Sometimes I need to load a few heavy pallets in the middle of the trailer so I came up with this solution. edit: a trailer that can manually adjust the starting position of pallet loading is better than ever before.

loki79uk commented 10 months ago

Yes I mean I want to move the front of the loading area backward with the control axis in game. Sometimes I need to load a few heavy pallets in the middle of the trailer so I came up with this solution.

So even with the layer stacking the pallets are too heavy to be loaded at the front?

I could certainly add a 4th option to move the front only with an axis control, so instead of lengthAxis, you could use e.g. offsetLoadingPositionFrontAxis="someAxis" and that would only move the front position back without moving the rear position. Is that what you actually asked for in the first place? :D

HatsuneKid commented 10 months ago

Yes I mean I want to move the front of the loading area backward with the control axis in game. Sometimes I need to load a few heavy pallets in the middle of the trailer so I came up with this solution.

So even with the layer stacking the pallets are too heavy to be loaded at the front?

I could certainly add a 4th option to move the front only with an axis control, so instead of lengthAxis, you could use e.g. offsetLoadingPositionFrontAxis="someAxis" and that would only move the front position back without moving the rear position. Is that what you actually asked for in the first place? :D

Yes yes yes!

loki79uk commented 10 months ago

Okay, so I think I will call it offsetFrontAxis as the other name is too long. I think there is a use case to have both lengthAxis and offsetFrontAxis active at the same time, as long as they use different spec_cylindered.movingTools.

loki79uk commented 10 months ago

Can you think of a use case for moving the rear position as well? I'm not sure that would ever be as helpful, you can always just stop loading if you want to.

HatsuneKid commented 10 months ago

For some special vehicles with extendable tails, movable rear position of loading area is more like an automated mechanism that eliminates the need for players to manually stop loading I think. It is not necessary but it could provide convenience or playability. Maybe someone could use this feature to implement new ideas.

loki79uk commented 10 months ago

I don't have time to test this properly now, but if you could try it and let me know, that would be really helpful! :D

[removed link - see later post for updated version]

All three should work together, even on the same axis: lengthAxis, offsetFrontAxis and offsetRearAxis

I could have easily got the directions mixed up though! Only lengthAxis should be affected by setting reverseLengthAxis="true".

HatsuneKid commented 10 months ago

Bad news. Testing offsetFrontAxis="AXIS_CRANE_TOOL2" and offsetRearAxis="AXIS_CRANE_TOOL2" Both offsetFrontAxis and offsetRearAxis are not working. Nothing changes in game. And no error displayed. Testing offsetFrontAxis="AXIS_CRANE_TOOL2" lengthAxis="AXIS_CRANE_TOOL2" together It shows that the whole loading area and trigger can move but the actual loading position is in the rear positions and can not be moved. The loaded pallets are even placed on the ground behind the trailer although it's already beyond the loading area, and they are still considered loaded by the trailer and can be unloaded.

HatsuneKid commented 10 months ago

Testing offsetFrontAxis="AXIS_CRANE_TOOL2" offsetRearAxis="AXIS_CRANE_TOOL2" together Nothing changes in game. Unable to use axis controls to move the loading area. All codes involved:

        <animation name="loadStartLine">
            <part node="0>0|3|0|0|0|16|1" startTime="0" endTime="2" startTrans="0 0 0" endTrans="0 0 -6"/>
        </animation>
...
            <movingTool node="0>0|3|0|0|0|16|1">
                <controls axis="AXIS_CRANE_TOOL2" invertAxis="false" mouseSpeedFactor="0.8" iconName="WORKING_WIDTH_TRANSLATE_X" />
                <animation animSpeed="0.4" animAcceleration="100" animName="loadStartLine" />
            </movingTool>
...
            <vehicleConfiguration>
                <loadingArea offset="0 1.185 -0.1" width="2.40" height="2.20" length="13.2" baleHeight="2.60" offsetFrontAxis="AXIS_CRANE_TOOL2" offsetRearAxis="AXIS_CRANE_TOOL2"/>
                <options enableRearLoading="true" enableSideLoading="true" isBaleTrailer="false"/>
            </vehicleConfiguration>
HatsuneKid commented 10 months ago

The functions of lengthAxis and offsetRearAxis is duplicate so that one of them can be removed I think. Perhaps their coexistence will cause conflicts.

loki79uk commented 10 months ago

Shall we find a base game vehicle we can test the same settings on together?

loki79uk commented 10 months ago

Maybe faster to talk about this on Discord? Loki_79

loki79uk commented 10 months ago

I found where it was going wrong. I had a check for loadArea.lengthAxis ~= nil, but I didn't add the new options there. I'm adding the option to use rotation as well now, so I'll post a new version later today.

loki79uk commented 10 months ago

This is working for me now, but needs some refinement: [removed link - see later post for updated version]

Try with this forestry vehicle, and open/close the grabber jaws:

        <vehicleConfiguration configFileName="data/vehicles/kesla/nd122/nd122.xml">
            <loadingArea offset="0 1.50 -0.80" width="2.20" height="1.4" length="5.1" offsetFrontAxis="AXIS_CRANE_TOOL"/>
            <options isLogTrailer="true"/>
        </vehicleConfiguration>
HatsuneKid commented 10 months ago

Testing on that vanilla forestry vehicle. Opening/closing the gripper jaws has no effect on both the loading area and the actual loading position of the logs. Testing on a rework trailer base on vanilla Krone ProfiLiner. In order to use Interactive Control to open its side curtain, I set its autoload to be a regular flatbed trailer.

            <vehicleConfiguration>
                <loadingArea offset="0 1.185 -0.1" width="2.40" height="2.20" length="13.2" baleHeight="2.60" offsetFrontAxis="AXIS_CRANE_TOOL2"/>
                <options enableRearLoading="true" enableSideLoading="true" isBaleTrailer="false"/>
            </vehicleConfiguration>

Now I can move the front of the loading area with axis control. It looks good in debug mode. But the actual loading area of the pallet is offset backwards by half the length of the initial loading area. I observed there's a green line at the middle bottom of the loading area which is also the starting point for pallet loading now.

A secondary suggestion is that if the size of the trigger remains unchanged when I move the front of the loading area, then it would be even better if the position of the trigger remains the same.

By the way, offset="0 1.10 -0.80" may suitable for KESLA 144ND cause its bottom is concave :) Due to some complex reasons, I currently do not have Discord account.

edit: I downloaded the latest file above. It seems to be a file that has not been updated yet. After I added offsetFrontAxis="AXIS_CRANE_TOOL" to KESLA 144ND. It has the same problem as my trailer, where the actual loading position of the logs is offset backwards by half the length of the loading area.

loki79uk commented 10 months ago

I never actually tested loading, just that the zones moved in the debugger view. It is odd that it doesn't work at all for you though?

image

image

The reason I didn't drop the zone down so low on that once, is that if you are not careful it can detect ojects OUTSIDE of the trailer as "loaded".

loki79uk commented 10 months ago

I see the issue with the starting position, I'll have a look at it now.

loki79uk commented 10 months ago

I think this is getting close to working now: FS22_UniversalAutoload.zip

HatsuneKid commented 10 months ago

Everything works fine now, thanks! We can now control the loading position of goods to achieve better load distribution and improve the driving experience for vehicles, not by manually loading but autoload!

loki79uk commented 10 months ago

Awesome - I think there are some more refinements possible:

HatsuneKid commented 10 months ago

edit: But in fact, I haven't tested the axis control in height and width yet, and it's unknown how it affects the size and position of the trigger.

HatsuneKid commented 10 months ago

After repeated testing, I have concluded that offsetFrontAxis and offsetRearAxis can only be used to shorten the length of the loading area from the front and rear. lengthAxis is used to extend the length of the loading area from rear. Shortening and lengthening are relative to the trigger that maintain the same length. I finally understand their function completely. Making length/height/width also move on different axis is quite useful but only for few special vehicles and the players who value precise operations.

By the way, Neither heightAxis nor widthAxis worked in my test. In addition, after using lengthAxis to extend the loading area, the trigger used to recognize the pallets on the vehicle still maintains its initial length, making it unable to recognize the front and back pallets of the vehicle, resulting in inconvenience during unloading. But I don't have any use cases for lengthAxis on any vehicle. Just found that it may cause inconvenience.

loki79uk commented 10 months ago

Height and width are restricted to things that actually move in those directions. Maybe I should open it up. Moving the wrong way is probably better than not moving.

For an example of an extending trailer, try one of the low loaders that came with the platinum/forestry dlc. They are supported by default. That is the reason I added the feature.

I'm busy with other things for a few days, but I'll work on finalising a new release of UAL.

HatsuneKid commented 10 months ago

I think of some trailers with cover which can provide a higher or wider pallet loading area when opened. This means that it's need to associate the change in loading area height/width with the cover animation which seems hard to achieve.

loki79uk commented 10 months ago

I made a new release, please let me know if you have any further suggestions! https://github.com/loki79uk/FS22_UniversalAutoload/releases/tag/v1.5.0.2

HatsuneKid commented 10 months ago

Cool. I suddenly realized that heightAxis and widthAxis didn't work because I forgot to set the corresponding translation axis in animation paragraph. Now they work.

loki79uk commented 9 months ago

I am just designing a new feature that may help you actually, although it will apply to the pallet and so will affect ALL trailers equally so maybe not as good.

The idea is to add an offset to certain pallet types, but ONLY when they are loaded first onto a trailer. If you set this to be a multiple of the pallet size, then it should start in the middle, fill to the back, and then fill in at the front again.

Does that sounds like it could work for your heavy pallets?

HatsuneKid commented 9 months ago

That feature is suitable for vanilla trailers. Although I'm not sure if other players need to optimize the position of heavy pallets on vanilla trailers with lower center of mass that are difficult to roll over. For me, the existing feature of freely adjusting pallet start loading point and loading area size is sufficient to meet my various needs :)

loki79uk commented 7 months ago

Closing as fixed.