OFPEC Forum

Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting General => Topic started by: Undeceived on 16 Sep 2010, 23:27:24

Title: Problem with script and with missing collision check
Post by: Undeceived on 16 Sep 2010, 23:27:24
Sorry guys!! This question is so complicated for me that I even don't know how to name the subject for it... I'll try to explain it.


I have 7 wooden crates which the player has to carry from A to B.
There is a trigger around each crate which gives the player the addaction menu "Lift crate". If the player doesn't want to carry it, he just needs to go away from the crate and the option will disappear.
But when then the player selects "Lift crate" from the action menu, the crate is attached to the player and he can move around with it.
He can drop the crate by choosing the action "Drop crate", which always is shown to him while he carries it.
After the crate is dropped, the action "Drop crate" is removed and the trigger which adds action "Lift crate" is setpossed on the crate - this way the player can repeat the whole procedure again if he wants / needs.

The problem begins here: When objects are attached to units, they don't collide with other objects or walls or units, etc. Another unit can pass through the attached crate and also the player can make the carried crate go through another crate.
When this happens though, the shit is not far anymore...

Because: If the player drops a crate "into" another (since there's no "collision check"), the addaction "Lift crate" will get buggy - suddenly I have 2 of them and even if I don't want to carry anything and go away, the action won't disappear!
I'm not quite sure why this happens, and I also made my best to avoid this bug, but I didn't succeed.

So here I am asking for your help for a workaround:


I saw two possibilities so far:

1. Is there a way to "enable" the collision check so that the player can't move crates through other crates / objects / persons? (Btw. this solution would help me as well on another part of my misison, where the player has to drag an injured one in a castle ruins and since there is no collision check for attached objects / units, the legs and half of his body keep disappearing in the wall of the castle...)



2. I would need a script code for the following solution:
When the player wants to drop the crate and it would drop into another one, it doesn't work and a hint appears: "There is no room for the crate right here! Drop it somewhere else!" - the crate stays attached to the player. He has to move a bit away (let's say 1,6m) and drop the crate there.

Well, this is the part, where I'm an absolut N00b...
Maybe this is a first thought on it though:


DropCrate.sqf:
Quote
if ((CarriedCrate distance OneOfTheOther6Crates) < 1.6) then
{
   hint "This is too close, your crate is floating in one other. There is no room for the crate right here!";
   _ExitTheScript_

} else
{  
   hint "Ok, you're far enough from the other crate(s).";
   //And then follows the DropCrate script, the crate is dropped, since there was enough space for it.  

};


But I have absolutely no idea how the code for the mentioned "CarriedCrate" and "OneOfTheOther6Crates" would look like...
Can you help me?

To be honest, I really would like to know the solution for both. :-[ Just in case.

Thanks for your patience and your help and especially your time!! :good:

Title: Re: Problem with script and with missing collision check
Post by: F2kSel on 17 Sep 2010, 03:14:58
I don't think there anyway to control collision detection.

As for carrying and dropping something I did get something working up to a point.  it only uses  triggers  so may be not easy to put into a script.

I've put it in file, it's not in anyway more than a poor example. I did have it working better but the game crashed just as I was about to save it and I couldn't how I had it.

http://www.sendspace.com/file/90rdze (http://www.sendspace.com/file/90rdze)

The crate is already attached and to drop it it's just radio alpha, try dropping it on the other crates and nothing will happen until you walk away.

The problem I had was getting separation between the carried box and those on the ground.

Anyway see how you go.

Title: Re: Problem with script and with missing collision check
Post by: Undeceived on 17 Sep 2010, 08:27:16
Wow, man!

This seems to be the solution! :o Thank you so much for your mission!

I'll try it out and report back here!


Well, unfortunately it didn't work. No idea why.
I made a workaround, but there is still the danger of bugs in it.
But nevermind.