Jump to content
KarmaT UK

Move boat into boat rack with script?

Recommended Posts

Hi I need to put a boat in a boat rack via script

Boat is B1, boat rack is BR1, so I tried

 

B1 moveInCargo BR1; 

 

But that dosent work and im not aware of other commands that might do it. Any ideas?

Share this post


Link to post
Share on other sites

Thanks for the reply, iv had a look and that setvehiclecargo seems to be the right one, but im having trouble getting it to work. I just tried

 

B1 setvehiclecargo BR1; 

That says "Init: Type bool, expected nothing"

 

So I swapped them round because its using the cargo vehicle first in the examples and tried

 

BR1 setvehiclecargo B1;

Same message

 

The example looks like this

 

_success = blackfish setVehicleCargo offroad; //true

 

but I don't understand why its got the _sucsess bit at the beginning or the //true at the end, if im right // is just commenting stuff out right? So is it because im not putting _success and what is that doing? why does it need to be there?

 

PS if its any help what im trying to achieve is putting the boats into the racks from the init at mission start, then using that for LVR custom inits to move it back into the rack when it respawns 🙂

 

 

Share this post


Link to post
Share on other sites

Check out this topic.

From what I read it might be easier to just use markers to parent the boat to the other boat. In that case you can still detach the boat whenever to use it.

Share this post


Link to post
Share on other sites

Cheers, il have a look. Tbh im starting to think if I can just use setpos to set them a couple feet above the racks and let them just fall onto them instead of having them actually on the rack. At least that way a transport heli could pick it up right away without them having to unload it first 🙂

Share this post


Link to post
Share on other sites

Check out,

Bis_Fnc_attachToRelative
AttachTo
and
objNULL
detach

You can create the whole game-mechanic yourself,

Parent B boat and C boat to A boat. B, C are the same type. B is the dummy model, C is the usable boat. Both boats are always there but toggle between which is hidden and which is shown. Tie that to an object (button) which adds an action. Detach C Boat when necessary.

There are better ways to do it for sure. But that'll get it done. When all is said and done I would use markers to create attach points instead of trying to attach everything to A boat.
This VR composition has all those functions set in a series of radio triggers so you can see how it works.
edit:
Keep in mind, canCollide

Share this post


Link to post
Share on other sites

Alright, so "setVehicleCargo" is the proper command, but it returns a boolean value when it's run to show whether the cargo loading was successful.

Code run in the init box of an object may never return a value, so just putting the following code in the init box will result in an error:

BR1 setvehiclecargo B1;

 To prevent your code from returning a value, you simply assign it to a local variable that's not used:

_null = BR1 setVehicleCargo B1;

This code doesn't return a value, so it can be used in an init box.

This should work give the result you're looking for

 

PS.

 

You can load vehicles into other vehicles (including racks) in the editor, by just dragging the icon of the cargo vehicle on top of the icon of the carrier vehicle.

  • Like 1

Share this post


Link to post
Share on other sites

You need to wait a moment between spawning the child vehicle and moving it into the parent vehicle.

 

logic should look like this:

 

- spawn boat rack

- spawn boat in a different position

- sleep 0.1

- rack setvehiclecargo boat

 

 

I also use setDir to match the direction of the boat with the rack before setvehiclecargo

  • Like 1

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

×