Skip to content
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

Add Vehicle Towing #8380

Merged
merged 28 commits into from
Oct 12, 2021
Merged

Add Vehicle Towing #8380

merged 28 commits into from
Oct 12, 2021

Conversation

TheCandianVendingMachine
Copy link
Contributor

When merged this pull request will:

  • Implements 2.06's setTowParent
  • Adds the ability to attach a rope to a car/tank and tow a given carx vehicle
  • Moves ACE_ropeX from ace_fastrope to ace_common
  • Adds 2 shorter ropes

Requires ARMA version 2.06. Any vehicle with simulation TankX or CarX can tow any vehicle with simulation CarX - this is an engine limitation and I don't really have any way to tell the user that is the case: any suggestions?

In Action: https://youtu.be/hSGIu9_rrCg

@jonpas jonpas modified the milestones: 3.14.0, Backlog Aug 14, 2021
@jonpas jonpas added the target/next-arma Requires something in arma dev branch label Aug 14, 2021
@severgun
Copy link
Contributor

severgun commented Aug 14, 2021

any suggestions?

Attach Tow Rope action throw hint / CBA_fnc_notify that vehicle can not be towed (due to game limitations) if vehicle simulation is not CarX.

@veteran29
Copy link
Member

Damn, I wanted to write something very similar this weekend ;-D

Nice one!

@veteran29 veteran29 self-requested a review August 14, 2021 17:06
@dedmen
Copy link
Contributor

dedmen commented Aug 18, 2021

Btw with 2.06 you can now also make custom rope models/textures.
Though I think the normal rope is appropriate here.

The problem that you have to use the brakes to "loosen" the brakes of the towed vehicle is weird ish.
I had to implement a special hacky way to start the vehicles physx simulation by force-rotating the front wheels.

I think the issue here might be that the rope actually stops and pulls back the heavy truck (in your video), so at the point where you affect force on the towed vehicle, you instantly stop.
The engine thing only works if the front vehicle is accelerating, not when its stopped.

One possible thing could be to use addForce or setVelocity to push the towed vehicle slightly.
But the big problem there is finding out when to do it and how hard to do it.

In my testing I always attached rope first and then setTowParent, not 100% sure if its relevant though

myRope = ropeCreate [f1_1, [0,-2,-1], f3_1, [0,1,-1], 10];
f3_1 setTowParent f1_1;

@dedmen
Copy link
Contributor

dedmen commented Aug 18, 2021

Actually, I just retested vehicle towing in our internal build, the brake loosening doesn't happen at all.
Something is broken.

Nvm, I was stoop and didn't call setTowParent 🤦

Nvm I still did a huge fuckup.
I do a linear interpolate using the speed delta between towing and towed vehicle to see how fast to turn the wheels.

in, inMin, inMxa, outMin, outMax
Interpolativ(mySpeed - parentSpeed, 0.1f, 10.f, 0.01f, 0.2f)

As you can see I fucked that up, parentSpeed is usually faster than mySpeed so you always end up with a negative here 🤦

@dedmen
Copy link
Contributor

dedmen commented Aug 18, 2021

Okey I fixed my interpolation and added a second factor.
If the rope is stretched more than 110%, it will force turn the wheels to "unstick" the vehicle, even if delta speed is low.
That should also help a bit when you don't gain enough speed to create high enough wheel torque for the towed vehicle.

Requires ARMA version 2.06. Any vehicle with simulation TankX or CarX can tow any vehicle with simulation CarX

TankX can also be towed, but in my tests most ropes were insufficient for the mass and just ripped.

@dedmen
Copy link
Contributor

dedmen commented Aug 18, 2021

Does that mean tanks and others with similar mass can't be towed by a single vehicle anymore ?

I don't understand the question, what do you mean by "anymore"? This is a new feature

@TheCandianVendingMachine
Copy link
Contributor Author

TankX can also be towed, but in my tests most ropes were insufficient for the mass and just ripped.

I just got my info from the Biki page. It explicitly says that TankX can't be towed at all

@dedmen
Copy link
Contributor

dedmen commented Aug 18, 2021

Wiki is outdated then

@severgun
Copy link
Contributor

TankX can also be towed, but in my tests most ropes were insufficient for the mass and just ripped.
What defines rope strength and can it be increased?

@dedmen
Copy link
Contributor

dedmen commented Aug 19, 2021

What defines rope strength and can it be increased?

You can make custom ropes that stretch less. If a rope stretches too far, it breaks.

class CfgVehicles {
	
	class Rope;
	class RopeDedmen : Rope {
		maxRelLenght = 1.1;
		maxExtraLenght = 20;
		springFactor = 1;
		segmentType = "RopeSegmentDedmen";	
        torqueFactor = 0.5;
		dampingFactor[] = {10,10,10};
	}
}

maxRelLenght -> max stretch before break
maxExtraLenght -> max stretch before break
springFactor -> how much it stretches

@Drofseh
Copy link
Contributor

Drofseh commented Oct 6, 2021

STR_ACE_logistics_rope_descriptionShort should be modified to indicate the ropes can be used for towing.

@PabstMirror PabstMirror removed the target/next-arma Requires something in arma dev branch label Oct 7, 2021
@PabstMirror PabstMirror modified the milestones: Backlog, 3.14.0 Oct 7, 2021
Copy link
Member

@veteran29 veteran29 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@654wak654
Copy link
Contributor

Not a merge blocker but some missing features I noticed while testing:

  • Ability to remove tow rope from the towing vehicle's side.
  • Some way to block vehicles from getting towed (could be based on vehicle lock).
  • Documentation (Doesn't need much).
  • Handle either vehicle being deleted. Looks like the engine already handles them getting destroyed, so this might be @dedmen territory. The issue is that one vehicle being deleted leaves the rope & helper object behind. Both being deleted leaves just the helper object behind. Attempting to get your rope back using it causes the following error:
 6:47:49 Error in expression <unit", "_parent", "_child"];
;

_parent removeEventHandler ["RopeBreak", _parent>
 6:47:49   Error position: <removeEventHandler ["RopeBreak", _parent>
 6:47:49   Error Type Any, expected Number
 6:47:49 File z\ace\addons\towing\functions\fnc_detach.sqf..., line 21

@jonpas
Copy link
Member

jonpas commented Oct 10, 2021

I would merge this now, but that script error is no good, we should cleanup helper/rope objects on vehicle deletion.

@TheCandianVendingMachine
Copy link
Contributor Author

I would merge this now, but that script error is no good, we should cleanup helper/rope objects on vehicle deletion.

probably fixed

@dedmen
Copy link
Contributor

dedmen commented Oct 11, 2021

We won't add handling for vehicle deletion on our side.
But deleted EH will fire before the vehicle goes away so that should be sufficient

@bux
Copy link
Member

bux commented Oct 11, 2021

Got this error after untowing and deleting a vehicle
20211011160137_1

16:01:31 Error in expression <unit", "_parent", "_child"];
;

_parent removeEventHandler ["RopeBreak", _parent>
16:01:31   Error position: <removeEventHandler ["RopeBreak", _parent>
16:01:31   Error Type Any, expected Number
16:01:31 File z\ace\addons\towing\functions\fnc_detach.sqf..., line 21
16:01:31 Error in expression <"ace_towing_parent", objNull];

_parent removeEventHandler ["Deleted", _hook get>
16:01:31   Error position: <removeEventHandler ["Deleted", _hook get>
16:01:31   Error Type Any, expected Number

I pulled the branch today, after the fix. Seems to still happen.

@bux
Copy link
Member

bux commented Oct 11, 2021

Is it possible to make some vehicles tow "heavier" vehicles? It's currently not possible for the recovery vehicle Nemmera (built on the Merkava Mk3 chassis) to tow e.g. the AAF Leopard.

@TheCandianVendingMachine
Copy link
Contributor Author

Is it possible to make some vehicles tow "heavier" vehicles? It's currently not possible for the recovery vehicle Nemmera (built on the Merkava Mk3 chassis) to tow e.g. the AAF Leopard.

I fixed the deleting issue finally: was a stupid reason, I forgot that the event handlers would still exist after you detach.

It's on the engine to make vehicles be able to tow other vehicles - as far as I know it has to do with the weight of the vehicles, and manually adjusting weights via script seems like a good way to cause issues

@jonpas jonpas changed the title Add vehicle towing Add Vehicle Towing Oct 12, 2021
@jonpas jonpas merged commit ca7fbe7 into acemod:master Oct 12, 2021
@jonpas jonpas added kind/feature Release Notes: **ADDED:** and removed kind/added feature labels Oct 14, 2021
AndreasBrostrom pushed a commit to AndreasBrostrom/ACE3 that referenced this pull request Dec 3, 2021
Co-authored-by: PabstMirror <pabstmirror@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Release Notes: **ADDED:**
Projects
None yet
Development

Successfully merging this pull request may close these issues.