Jump to content
daniel_yates

How do you add Physics to custom objects which do not have them? (Not my objects.)

Recommended Posts

So, I am using a mod called ACE3 along with custom objects like barriers from the PLP Urban Pack. My idea was that so that people would be able to pickup these custom objects using ACE (works fine) and place them onto the back of a truck. Whilst some objects in this pack (traffic cones, etc.) do work, others like the barrier I have already mentioned don't - well they sort of do. ACE recognises that the object doesn't have any sort of physics attached to it, so instead of leaving it to just float in the air, it makes the objects shoot straight down to the ground, going straight through anything below it (e.g. in my case the truck I was trying to load it on).


 


So I guess what I'd be looking for is either someone to come up with some monumentally amazing solution, or if I can simply add the physics of one object to these objects which do not have any.


 


If you have any questions let me know, I'm going to be watching this page religiously! Thanks.


 


P.S. I know the barriers do not have any physics because if you place them in the air in the editor, unlike some of the traffic cones in the pack, they stay floating in the air, rather than falling to the ground like the cone(s).


Share this post


Link to post
Share on other sites

My fish and bird scripts all use a small object that has physics ("Land_CanOpener_F"), and attach the non-physics object to it.  Then use physics commands (setvelocity) on the object.  SetPos the physics object where you want it, and the attached non-physics object will move with it.

 

Check out JBOY Fish Jump as an example.

 

Maybe this idea will work for you.  I'm pretty sure you can't "add physics" to an object.

 

BTW, welcome to the forums!

  • Like 1

Share this post


Link to post
Share on other sites

My fish and bird scripts all use a small object that has physics ("Land_CanOpener_F"), and attach the non-physics object to it.  Then use physics commands (setvelocity) on the object.  SetPos the physics object where you want it, and the attached non-physics object will move with it.

 

Check out JBOY Fish Jump as an example.

 

Maybe this idea will work for you.  I'm pretty sure you can't "add physics" to an object.

 

Righto, thanks for the quick reply, would you be able to expand a little more on the steps I'd have to take? And also do you think this would solve the problem of ACE just sending the object to the ground because it can't find any sort of 'physics' file or whatever it searches for? Thanks.

Share this post


Link to post
Share on other sites

I don't use ACE so I don't know what its doing.  If ACE allows you to pick up items and put them in trucks, then ACE is scripting that.  It's possible you could pick a physics object that is smaller than the non-physics object you want.  I'm away from my Arma computer for two weeks, but the code would look like this:

PhysObj = "Land_CanOpener_F" createVehicle [10,10000,0];  // Maybe you want a larger physics object like a barrel?
PhysObj disableCollisionWith NonPhysObj;
NonPhysObj attachTo [_physObj,[0,0,0]];  // Adjust attachTo relative pos until it looks good
// Physics object should be smaller than non-physics object, so player can't see it (its hidden inside non-physics object
// Use PhysObj as the object name you pass to ACE

However, if ACE is magically working at run time by finding  objects near player, this might not work.   ACE would have to sense the physics object and not the non-physics object.

 

Please describe how you are interacting with ACE currently.  I'm off for a mtn bike ride, so won't be checking this forum again for 3 hours or more.

Share this post


Link to post
Share on other sites

I don't use ACE so I don't know what its doing.  If ACE allows you to pick up items and put them in trucks, then ACE is scripting that.  It's possible you could pick a physics object that is smaller than the non-physics object you want.  I'm away from my Arma computer for two weeks, but the code would look like this:

PhysObj = "Land_CanOpener_F" createVehicle [10,10000,0];  // Maybe you want a larger physics object like a barrel?
PhysObj disableCollisionWith NonPhysObj;
NonPhysObj attachTo [_physObj,[0,0,0]];  // Adjust attachTo relative pos until it looks good
// Physics object should be smaller than non-physics object, so player can't see it (its hidden inside non-physics object
// Use PhysObj as the object name you pass to ACE

However, if ACE is magically working at run time by finding  objects near player, this might not work.   ACE would have to sense the physics object and not the non-physics object.

 

Please describe how you are interacting with ACE currently.  I'm off for a mtn bike ride, so won't be checking this forum again for 3 hours or more.

ACE doesn't do anything magic, for custom objects there's a little piece of code you put into the object's init box and then it allows you to interact with it, positioning it away from the player at the distance specified in the init. Also, where do I put this code that you gave?

Share this post


Link to post
Share on other sites

 

where do I put this code that you gave?

Now that I see the PLP barrier object and understand your problem better, I'm not sure my suggestion is good for you.  But if you want to try it, then do this:

 

1. Place a vanilla editor object that the barrier will be attached to.  Maybe the dented can object, so you don't mind seeing it on the road, or a pencil because its small.  Name this object in the editor as "Barrier1Phys" (or whatever you want).

2. Place the PLP barrier object and name it "Barrier1".  In the PLP barrier object's init, put this code:

Barrier1Phys disableCollisionWith Barrier1;
Barrier1 attachTo [Barrier1Phys,[0,0,0]]; // Adjust rel pos until barrier looks right.
Barrier1 setdir getdir Barrier1Phys;

3. Put the "little piece of Ace Code" you mentioned in the Barrier1Phys object's init so Ace can interact with it.

 

If ACE can interact with any physics object then this should work.  ACE will be moving the physics object, but since the PLP barrier is attached to it, it will look like the player is moving the PLP barrier.

 

Note:  If the init code shown in step 2 doesn't work, then put it within a spawn call like this:

nul = [] spawn {
 Barrier1Phys disableCollisionWith Barrier1;
 Barrier1 attachTo [Barrier1Phys,[0,0,0]]; // Adjust rel pos until barrier looks right.
 Barrier1 setdir getdir Barrier1Phys;
};
  • Like 2

Share this post


Link to post
Share on other sites

 

Now that I see the PLP barrier object and understand your problem better, I'm not sure my suggestion is good for you.  But if you want to try it, then do this:

 

1. Place a vanilla editor object that the barrier will be attached to.  Maybe the dented can object, so you don't mind seeing it on the road, or a pencil because its small.  Name this object in the editor as "Barrier1Phys" (or whatever you want).

2. Place the PLP barrier object and name it "Barrier1".  In the PLP barrier object's init, put this code:

Barrier1Phys disableCollisionWith Barrier1;
Barrier1 attachTo [Barrier1Phys,[0,0,0]]; // Adjust rel pos until barrier looks right.
Barrier1 setdir getdir Barrier1Phys;

3. Put the "little piece of Ace Code" you mentioned in the Barrier1Phys object's init so Ace can interact with it.

 

If ACE can interact with any physics object then this should work.  ACE will be moving the physics object, but since the PLP barrier is attached to it, it will look like the player is moving the PLP barrier.

 

Note:  If the init code shown in step 2 doesn't work, then put it within a spawn call like this:

nul = [] spawn {
 Barrier1Phys disableCollisionWith Barrier1;
 Barrier1 attachTo [Barrier1Phys,[0,0,0]]; // Adjust rel pos until barrier looks right.
 Barrier1 setdir getdir Barrier1Phys;
};

Wow, some people really are so talented. This works absolutely fantastically, and for objects which otherwise don't have physics already, it's a great workaround and is exactly what I was looking for - this has effectively made my day. Can't thank you enough, this is awesome. (Knowing me I'm probably going to come back here with more questions about it haha). Thanks.  :D

  • Like 1

Share this post


Link to post
Share on other sites

Sweet.  Another satisfied customer!  Glad it worked out for you.

  • 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

×