Jump to content
Sign in to follow this  
Yolo Joe

Need help with towing script!

Recommended Posts

How can I improve this and make car #2 not flip?

(Thanks to BlaCkShad0w for helping me out)

 
Rope = ropeCreate [car1, [0,-3,0], car2, [0,1.5,-1], 10];

Edited by Chillroy

Share this post


Link to post
Share on other sites

Care to share the code? Well, unless there's already a "rope" expert among us that can point out your problem by watching.

Share this post


Link to post
Share on other sites

I think Tajin sums the reason for this happening in the ropeCreate command wiki page comment section. I would recommend trying to use the ropeAttachTo or something similar to see if there is a better attach point that combats the "friction" created between the vehicle towing and the vehicle being towed.

Edited by JShock

Share this post


Link to post
Share on other sites
Any workaround? Like editing the mass of the vehicle I'm towing?

I personally jumped straight to making the towed vehicle float ever so slightly above the ground :D.

Share this post


Link to post
Share on other sites

Jshocks method would probably work, the real problem under the hood is that vehicles breaks are always applied 100% when its not moving (regardless of if anyone is inside or not) so they don't roll away from players. When you try to drag it with the rope since breaks are applied the physics get put all out of whack and it rolls around like it was hit by an 18 wheeler going at top speed.

Share this post


Link to post
Share on other sites

I tried also fiddling with setMass. It doesn't help. It just allows the towing duo to get underway flipping faster.

Share this post


Link to post
Share on other sites
How? :P

Concept:

1. Set the cars altitude/level above the ground a couple few inches or so.

2. Constantly update based on the angle of the terrain that the car is moving over (so it "follows" the terrain, instead of "floating")

How to do it:

No clue, I'm a concept guy :D.

Share this post


Link to post
Share on other sites

it'll probably be really inefficient and will go clunk clunk, but perhaps use a while loop to set its position to where it currently is on the X and Y axis, and set its Z axis (or in simpleton terms, height) to 2 or 3 over and over every like 0.001 seconds. A variable to stop it once the rope breaks or it is detached from the towing vehicle would be needed as well.

I don't have time to formulate the actual code, but based on this if you go trawling through the biki you might be able to slap something together and learn a bit of SQF in the process.

Share this post


Link to post
Share on other sites

Been trying that stuff, setvector the vehicle, setpos flat etc in a loop. I didn't go at it too hard, but none of it worked well.

Share this post


Link to post
Share on other sites

Been struggling with this one too. Lowering the center of mass made it possible to drag the vehicle without flipping, ofcourse the brakes are still on.

A loop might get the job done with some fiddling but is really not a feasible solution at all.

What we need is this:

vehicle setHandbrake true/false

Share this post


Link to post
Share on other sites
Been struggling with this one too. Lowering the center of mass made it possible to drag the vehicle without flipping, ofcourse the brakes are still on.

A loop might get the job done with some fiddling but is really not a feasible solution at all.

What we need is this:

vehicle setHandbrake true/false

Would enableSimulation do anything, or would it just remain the same, but logically you would think the "brake" would be disabled along with it, but now that I think about it, probably not.

Share this post


Link to post
Share on other sites

I guess we could use attachTo, stick the car on something with less friction and then tow that instead.

- - -

Another method would be to utilize something that I've been using for "rope simulation" before those cool new ropes where implemented.

1 Define the length of the rope.

2 Run a loop

3 check the distance between the vehicles

4 if the distance exceeds the length of the rope, apply the speed of the first vehicle to the second, combined with the normalized direction vector between them

It takes some fiddling to get it right (dampening and whatnot). But maybe it works if we combine that old technique with the new ropes.

Oh and what JShock said about changing the "vectorUp" of the car, based on the angle of the terrain could also come in handy.

I think the attachTo method will work better though.... and much much easier.

Edited by Tajin

Share this post


Link to post
Share on other sites
No not really.

If you kept the second cars velocity the same as the first it shouldn't flip, but I am not exactly sure how to do it. It needs to be looped very frequently to stop it looking like its jumping and the first cars speed should be limited to lessen the chance of it glitching.

_vel = velocity car1;
car2 setVelocity _vel

That works using the debug menu but I am not sure how to implement it as a loop, any suggestions?

Share this post


Link to post
Share on other sites

This:

1 Define the length of the rope.

2 Run a loop

3 check the distance between the vehicles

4 if the distance exceeds the length of the rope, apply the speed of the first vehicle to the second, combined with the normalized direction vector between them

If you just use setVelocity all the time, then thats almost the same as using attachTo. Won't look like it's beeing pulled.

IMHO, that way we would loose all the nice things that the new rope-object simulates.

Try it with the attachTo instead. Thats how I'm doing it so far.

Share this post


Link to post
Share on other sites
This:

If you just use setVelocity all the time, then thats almost the same as using attachTo. Won't look like it's beeing pulled.

IMHO, that way we would loose all the nice things that the new rope-object simulates.

Try it with the attachTo instead. Thats how I'm doing it so far.

If you just use set Velocity the car should not turn with the car and the roll and pitch factors should be effected by the environment not the relative factors given by car1. That would mean that at least some of the rope-object simulations would still be there right?

Share this post


Link to post
Share on other sites
loop = alive car1;
while {true} do {
_vel = velocity car1;
car2 setVelocity _vel
};

Would that work?

Nope, you really need alot more fiddling around to simulate correct physics :)

Looks pretty funny:

Share this post


Link to post
Share on other sites
Nope, you really need alot more fiddling around to simulate correct physics :)

Looks pretty funny:

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. :)

Edited by TheFinanator

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  

×