Jump to content
Sign in to follow this  
Beny.cz

Problem with attachTo

Recommended Posts

Hi,

Me and my friend are working on a coop mission where players start on an LHD. There are some vehicles avaible - MH60, Harrier, 4 Trucks, 4 105s and more.

The players shall be able to attach trucks under helis and to tow howitzers behind trucks.

I managed to do that in this test mission I created: http://leteckaposta.cz/538759655

OK, so it works fine.

The thing is, in the current status, only ONE howitzer can be towed by ONE truck and ONE truck by the MH60.

So, what is the easiest way to make all the howitzers towable by all the trucks?

Thanks, Beny

Share this post


Link to post
Share on other sites

You can only do one because your script is using the unit names, in this case "nakladak" and such. You either have to make a script for each group of stuff to be attached, or better yet, make new scripts that will make the units into private variables so you can use the same script on all of them.

For example, instead of "nakladak", you'll end up using something like "_nakladak = this select #" and then "_nakladak attachTo...". Sorry don't really have time to answer more thoroughly right now but will later if still needed.

Share this post


Link to post
Share on other sites

I think I get the idea, but I dunno where to put the arguments.

Share this post


Link to post
Share on other sites

Depends how you create your script. For example, if you have this:

_chopper = _this select 0;
_truck = _this select 1;

_truck attachTo [_chopper[#,#,#]];

Then when you call the script in game, the chopper name will be your first argument, followed by the truck name. Like this:

[heli1, nakladak] execVM "script.sqf";

Edited by JDog

Share this post


Link to post
Share on other sites

Great, I got it to work, thanks man.

Now I have a small problem. When a howitzer is detached from the heli, it gets stucked in air.

Is there any way how to make it "land" ?

Share this post


Link to post
Share on other sites

Yea I don't think static weaonry (at least not the M119s, I know from experience) are affected by physics, and they sit wherever you place them in space. You'd have to use setPos to bring it down, but then it'll look like it's teleporting and not falling... which shouldn't be an issue if it's only a few feet off the ground anyway.

this setPos [getPos this select 0, getPos this select 1, 0];

Share this post


Link to post
Share on other sites

Yeah, you have to attach something to it that does effect physics. like a deletecollected book. :)

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  

×