Jump to content
MechSlayer

Objects detach when player enters in a vehicle

Recommended Posts

short question, short answer. I like it.

  • Like 1
  • Haha 1

Share this post


Link to post
Share on other sites

Did something like this for my radio script, back when it used to attachTo a radio to the player:
 

player addEventHandler["GetInMan",{ ((attachedObjects player)#0)attachTo[objectParent player,[0,0,0]]; }};
player addEventHandler["GetOutMan",{ ((attachedObjects objectParent player)#0)attachTo[player,[0,0,0]]; }};

 

  • Like 1
  • Confused 1

Share this post


Link to post
Share on other sites
11 hours ago, phronk said:

Did something like this for my radio script, back when it used to attachTo a radio to the player:
 


player addEventHandler["GetInMan",{ ((attachedObjects player)#0)attachTo[objectParent player,[0,0,0]]; }};
player addEventHandler["GetOutMan",{ ((attachedObjects objectParent player)#0)attachTo[player,[0,0,0]]; }};

 

Clever.

Share this post


Link to post
Share on other sites
2 hours ago, johnnyboy said:

Clever.

That can't work for several reasons:

-  the least is the syntax.

- The main is that ((attachedObjects objectParent player)#0)  will always return objNull in the getoutMan EH. You need to script with parameters (it's better) but also define the object you need to reach.

- The secondary is that can't work as is, if two or more players are in the same vehicle.

Not mentioning the flickering problem in MP.

Share this post


Link to post
Share on other sites
44 minutes ago, pierremgi said:

That can't work for several reasons:

-  the least is the syntax.

- The main is that ((attachedObjects objectParent player)#0)  will always return objNull in the getoutMan EH. You need to script with parameters (it's better) but also define the object you need to reach.

- The secondary is that can't work as is, if two or more units are in the same vehicle.

Not mentioning the flickering problem in MP.

 

attachto simply destroys in game performance, both in SP and in MP but it is particularly devastating in MP.

 

The problem is that it updates the objects attached position every second and with just more than 2 attached objects it can cause serious delays to other scripts not to mention what it does to network performance.

 

It is also know to mess with the object's physics if the object has complex physics.

 

Adding the attached item to a "virtual inventory" is the way to go for me, even if it doesn't look as realistic (you don't see the object). 

 

At least until BI fixes/optimizes the the attachTo command to perhaps allow the object to loose all its physics and position calculations as an optional parameter. There shouldn't be a reason to double calculate the position of a attached item since its position is the same as the unit/object it is attached to minus the offset (Yet this is Arma and it does double/triple checks on things it doesn't need to).

 

So, my suggestion is to stay away from attachto as much as possible 😃 

  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, johnnyboy said:

Did something like this for my radio script, back when it used to attachTo a radio to the player:

I think you can probably make it work...he was just giving an example from memory, not working code I believe.  He says "Did something like this..."

Share this post


Link to post
Share on other sites
2 minutes ago, LSValmont said:

So, my suggestion is to stay away from attachto as much as possible

Maybe sound advice for MP.  But I use attachTo all the time in many scripts (flying chickens, attacking dogs, birds of prey, fish jumps, civilian long boats, etc.).  attachTo opens up many possibilities.

  • Like 3

Share this post


Link to post
Share on other sites
26 minutes ago, johnnyboy said:

Maybe sound advice for MP.  But I use attachTo all the time in many scripts (flying chickens, attacking dogs, birds of prey, fish jumps, civilian long boats, etc.).  attachTo opens up many possibilities.

 

Agreed! attachto is a great immersion creating command that should really be optimized by BI so we can get its full potential without any regrets in our missions.

 

PS: I love have you've done with your civilian long boats script!

  • Like 2

Share this post


Link to post
Share on other sites

Right! (for both nice johnnyboy scenarios in SP, and for ugly MP rendering of attachTo command).

I tested with HALO jump (just the current backpack on ventral during the chute). It's fine for the player, badly flickered for other units jumping at the same time. I abandoned the idea to make it work for every units. Non-played ones simply recover their backpack after touching ground.

 

It's a great idea to "put" (add) the object inside the cargo (or to delete it, recover it when getting out).

  • Like 1

Share this post


Link to post
Share on other sites

ACE does a similar thing with chemlights. They detach on GetIn, store it in a variable on the player, and reattach on GetOut. But they don't get attached to the vehicle itself.

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

×