Jump to content
Sign in to follow this  
Yolo Joe

Need help with towing script!

Recommended Posts

It needs to be way more into the physics for both cars together and individually, that's why I brought up the point of having it somehow "follow" the terrain so it doesn't look clunky and weirdly floating. The other issue as well is that I'm not sure how taxing setting/finding velocities on two different vehicles via while loop is on performance but if you have a lot of people towing at the same time I would imagine it would be pretty detrimental (but I could be wrong).

Share this post


Link to post
Share on other sites
It needs to be way more into the physics for both cars together and individually, that's why I brought up the point of having it somehow "follow" the terrain so it doesn't look clunky and weirdly floating. The other issue as well is that I'm not sure how taxing setting/finding velocities on two different vehicles via while loop is on performance but if you have a lot of people towing at the same time I would imagine it would be pretty detrimental (but I could be wrong).

Has anyone tried to loop a function that simply lifts the car half a meter or do into the air? It might reduce wheel friction making it possible to drag?

Share this post


Link to post
Share on other sites
I see well perhaps something more like this?

loop = alive car1;
while {true} do {
_vel = velocity car1;
if (_vel > 3) then { car2 setVelocity [_vel select 0, 0, 0] } else { car2 setVelocity [0, 0, 0] }

};

or something like

loop = alive car1;
while {true} do {
_vel = velocity car1;
if (_vel > 5) then { car2 setVelocity [5, 0, 0] } else { car2 setVelocity [0, 0, 0] }
};

I need some way to prevent negatives on the X angle I think but are the variables dependent of the entity or the world?

I think I am getting a bit out of my depth though. :)

Practically a loop is not going to cut it. You can probably simulate the correct physics but it takes alot of work and performance wise in a multiplayer game it's not ideal.

The loop method was used pretty neatly in a towing script for aircraft in A2, can't remember the correct one but it looked pretty realistic.

Instead all we need is a way to not have the breaks applied 24/7 on the vehicle :)

Share this post


Link to post
Share on other sites

Instead all we need is a way to not have the breaks applied 24/7 on the vehicle :)

That would be awesome. Basically the fastest way to stop a vehicle is to hop into the passenger seat or eject. I'm also working on a towing script but I'm afraid even I can simulate proper physics, it will be glitchy.

Share this post


Link to post
Share on other sites
Practically a loop is not going to cut it...

...Instead all we need is a way to not have the breaks applied 24/7 on the vehicle :)

I know I'm repeating myself but...

using attachTo with another physics object that doesn't have rubber tires coated with superglue works pretty well.

That is both the easiest and probably also the most realistic workaround.

Share this post


Link to post
Share on other sites

Yes ofcourse attachTo has been used for a long time and is really easy to do.

But wasn't the point of this thread to actually tow using the ropes? :)

Edit: Just re-read your post, haven't actually tried that. Maybe best I'll go to sleep.

Edited by Viba

Share this post


Link to post
Share on other sites
I know I'm repeating myself but...

using attachTo with another physics object that doesn't have rubber tires coated with superglue works pretty well.

That is both the easiest and probably also the most realistic workaround.

Unfortunately with attachTo you lose some simulation, it doesn't look entirely realistic, and there are collision anomalies as well. And, there are already quite a few attachTo-wrapper towing scripts out there already...

That said, with the rope approach ... The vids posted don't look anything like towing a vehicle. No where on YouTube can I find a video of a vehicle being towed solely by a length of stretchy rope. I think a more successful script would be to simulate a vehicle recovery winch system, for the front of some vehicles, and actionable by the player.

- player walks around to front of his winch-equipped vehicle.

- player 'grabs' the winch from his vehicle via addAction and anim.

- player walks the winch a certain distance to the second vehicle. a loop checks distance and terminates the script if he gets too far.

- attaches it to second vehicle. (can the rope attach to a player, so as to simulate walking with a rope in hand and attaching it to the vehicle by hand?)

- player gets in the first vehicle and has a 'Winch' action, which when actioned, removes the winch action and pulls the second vehicle toward the players vehicle, and also allows the player to reverse his own vehicle, with some setMass/setCenterOfMass maths applied. Also a get velocity loop to ensure the player is not driving forward, in which case the winch system terminates, to prevent sillyness.

Share this post


Link to post
Share on other sites
The vids posted don't look anything like towing a vehicle. No where on YouTube can I find a video of a vehicle being towed solely by a length of stretchy rope.

Really?

http://www.lmgtfy.com/?q=towrope

And you're somewhat missing the point. This isn't really about what features a towing system should have. It's just about getting around the sticky-wheels problem.

Share this post


Link to post
Share on other sites

Has anyone tried putting an AI inside the vehicle.

If it works you could hide the ai with:

objectname hideObjectGlobal true;

Share this post


Link to post
Share on other sites
Has anyone tried putting an AI inside the vehicle.

If it works you could hide the ai with:

objectname hideObjectGlobal true;

Just putting a guy in doesn't help. He still keeps the brake pedal down.

Share this post


Link to post
Share on other sites

on cfgVehicles >> "C_Hatchback_01_F" there is a parameter named brakeIdleSpeed..

WIKI

brakeIdleSpeed is speed in m/s under which the brakes are automatically applied to the vehicle. This speed should be reasonably low, higher value would mean strange breaking of slow cars, too low value would cause inability to stop the car.

(maybe we can override this parameter)

Edited by KoVValsky

Share this post


Link to post
Share on other sites
on cfgVehicles >> "C_Hatchback_01_F" there is a parameter named brakeIdleSpeed..

WIKI

brakeIdleSpeed is speed in m/s under which the brakes are automatically applied to the vehicle. This speed should be reasonably low, higher value would mean strange breaking of slow cars, too low value would cause inability to stop the car.

(maybe we can override this parameter)

This can only be done with mods.

Share this post


Link to post
Share on other sites

You can change it to zero and it doesn't do anything useful. The issue is that brakes are automatically applied when no-one is in the car. This parameter only affects the speed that the brakes are applied when someone is in the car.

Just tried towing a vehicle in the editor with brakeidlespeed set to 0 and it still has locked brakes (engine on or off) if there is no-one in the car.

Share this post


Link to post
Share on other sites

Arma 2 had an invisible man unit. The last time I checked, A3 doesn't have one. I'm thinking put him in the driving seat to get the brakes off.

edit.. kill him once he's in the seat. The brakes should stay off.

Share this post


Link to post
Share on other sites
Arma 2 had an invisible man unit. The last time I checked, A3 doesn't have one. I'm thinking put him in the driving seat to get the brakes off.

edit.. kill him once he's in the seat. The brakes should stay off.

I think the hand brake still activates when the vehicle stops. Just like when you shoot a driver of a moving car.

Share this post


Link to post
Share on other sites

Yeah, first the car rolls freely and when it stops the wheels are locked. And you can only keep the car moving with a living foot on the gas pedal. AFAIK.

Share this post


Link to post
Share on other sites

Yup doesn't help having AI or actual player inside the vehicle, brakes are still on.

Share this post


Link to post
Share on other sites

Anyone tried setVelocityTransformation ?

setVelocityTransformation example

/*
Rope Towing Script for Arma3
--->> setVelocityTransformation
Not a bad result with only a little stutter and better than either setVelocity or attachTo as all vectors/directions are matched without rigid link, 
but strage things can happen if the rope is too short or _time value is too low.

0 = [car1,car2] execVM "tow.sqf";
*/

private ["_v1","_v2","_rope","_dist","_time","_spd","_v1_pos","_dir","_newPos","_arr"]; 

_v1 = _this select 0;
_v2 = _this select 1;

_rope = ropeCreate [_v1, [0,-3,0], _v2, [0,1.5,-1], 10];

_dist = 12;

while {alive _v1} do 
{

   	_time = 0.07;//set this too low and bungee effects!
_spd = speed _v1;

_v1_pos = getPosASL _v1;

_dir = (getDir _v1) + 180;
_newPos = 
[
(_v1_pos select 0) + _dist*sin _dir, 
(_v1_pos select 1) + _dist*cos _dir, 
_v1_pos select 2
];

  	_arr = [getPosASL _v2, _newPos, velocity _v2, velocity _v1, vectorDir _v2, vectorDir _v1, vectorUp _v2, vectorUp _v1, _time];
  	if (_spd > 1) then {_v2 setVelocityTransformation _arr};
};

edit: something needs adjusting in the array - works well on flat terrain nut goes FUBAR on hills - towed car floats.

Edited by Falsche9

Share this post


Link to post
Share on other sites

I guess the only viable solution would be to remove the automatically applied brake and add something similar to the wheel brake on choppers for cars and other ground vehicles.

Would probably require a good chunk of work from BIs side.

Share this post


Link to post
Share on other sites

As soon as cars velocity changes from 0, the brakes are released. So when car1 attach point is _ropeLength (or just under) away from car2 attachpoint setVelocity to some low value.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×