When dropping an object that has another object attached to it, the collision decouples from the attached object

I’m working on a VR project based on the VR template, where the player can pick up a weapon and attach items to the weapon while it’s being held. It’s also possible to attach items to the weapon even if it’s not being held in the hand. If the player attempts to attach an item to the weapon while holding the weapon, a collision bug occurs once the weapon is dropped. I was able to reproduce the error in a separate test project I created to isolate the behavior. A link to the project is included below.

Steps to reproduce:

  1. Open the included project in Unreal Engine 4.13: AttachTest.zip
  2. Select “Play this level in VR”.
  3. Teleport over to table with objects and pick up the gun by grabbing the pistol grip.
  4. Grab a magazine and insert the non-flared end into the magazine well. The magazine will automatically attach to gun prior to entering the magazine well.
  5. Drop the gun onto the table so that the magazine will hit first.

Depending on the orientation of the gun when it is dropped, it should immediately experience unexpected physics behavior. Further testing revealed that the collision for the attached magazine is somehow decoupling from the magazine and remaining frozen in space. Using other physics objects in the scene, I am able to locate the invisible collision hull, which otherwise remains invisible even when using the “show collision” command in the console during play.

Steps to reproduce:

  1. Open the included project in Unreal Engine 4.13: AttachTest.zip
  2. Select “Play this level in VR”.
  3. Teleport over to table with objects and pick up the gun by grabbing the pistol grip.
  4. Grab a magazine and insert the non-flared end into the magazine well. The magazine will automatically attach to gun prior to entering the magazine well.
  5. Orient the gun so that it is horizontal, with the magazine pointing roughly toward the stack of blue boxes. This positioning helps ensure the gun lands on the table in a predictable fashion for the next step.
  6. Drop the gun onto the table so that it must fall a short distance before landing on the table. Line the magazine up with the square tiles on the table to make it easier to locate the invisible collision volume in the next step.
  7. Grab another magazine and orient it so that it is horizontal and a short distance above where the magazine was before the gun was dropped.
  8. If dropped from the correct location, the magazine will land on the stationary collision volume that was originally part of the attached magazine.
  9. While using the trigger to ball up the fist, push the gun around. The gun will respond to force applied by the fist, but the attached magazine will not.
  10. Pick up the gun by grabbing the pistol grip. The stationary collision volume will vanish, causing the second magazine to drop to the table. The collision volume will return to the attached magazine, and will push other objects out of the way if the gun is moved so that the magazine collides with other physics objects.
  11. At this point, steps 5-10 can be repeated without any change in behavior.

This behavior only manifests itself if the the gun is being held when the magazine is attached. If the gun is sitting on the table when a magazine is attached, behavior for the most part is as expected.

Steps to reproduce:

  1. Open the included project in Unreal Engine 4.13: AttachTest.zip
  2. Select “Play this level in VR”.
  3. Teleport over to table with objects and pick up a magazine.
  4. Insert the non-flared end into the magazine well into the gun as it rests on the table. The magazine will automatically attach to gun prior to entering the magazine well.
  5. Ball up the fist and attempt to push the gun around by pushing at the gun itself and then at the attached magazine. There do appear to be some physics quirks, but otherwise the gun and attach magazine move as expected.
  6. With a magazine already attached to the gun, pick up the gun by its pistol grip.
  7. Move the gun around so that the attached magazine collides with other physics objects. They should move out of the way as expected.
  8. Drop the gun while the magazine is attached.
  9. At this point, steps 5-8 can be repeated without any change in behavior.

The only difference I can see between the two scenarios is that physics seem to have a problem only if physics simulation is NOT enabled at the time the magazine is attached (due to the gun being attached to the player’s hand.) If physics simulation is enabled at the time the magazine is attached, then the problem does not occur. I tried a workaround that involved detaching the gun from the player’s hand just before the magazine attaches, but that seemed to cause other unpredictable behavior if done multiple times in a row with 4.13. I cannot recreate the project in 4.14 at this time due to a known bug involving the importing of skeletal meshes that is scheduled to be fixed in 4.14.1. I tried opening the existing project to 4.14, but the error manifests itself in a more unpredictable manner.

Let me know if you need any further info…

Hello Klasodeth,

After testing the project provided it appears that this is working as intended. You appear to be attaching the magazine to the hand and not the gun. I have provided a few pictures to help explain what I did to get this working on my end. I hope that this information helps.

Example:

Here I replaced get root component with a reference of the magazine well. (Note you will need to cast to make this work)

Here I created a new Collision channel in the project settings and gave it to the magazine.

Here I set the new collision channel to be ignored by the gun.

Make it a great day

Thank you for the response! I made the changes you suggested, but it seems to have made the problem worse. While I no longer have the stationary invisible collision volume problem I originally reported, the magazine now has very limited collision. Here’s a video showing the collision issue:

Attach Test Version 2

The magazine fails to collide with the world while attached to the gun, and reacts to other objects only in limited circumstances. For collision purposes, I’d like the magazine to act as if it were a solid part of the gun, capable of interacting with other objects the way the gun itself does. For comparison, here’s a video showing how I’d like the magazine to react while attached to the gun:

Attach Test Version 1 – Attaching the magazine while not holding the gun

That video was recorded using the original version of the test project. The magazine reacts exactly how I’d like it to while attached to the gun, with the problem being that I get that behavior only if I attach the magazine to the gun while I’m not holding the gun. If I hold the gun, I get the behavior seen in the first 58 seconds of this video:

Attach Test Version 1 – Attaching the magazine while holding the gun

I forgot to show it in the previous video, so here’s one more video with “show collision” enabled:

Attach Test Version 1–Test 2

In the video, the rogue collision volume is not visible, even though its existence is clearly proven by the behavior of other objects. It also shows that the volume is stationary, as its position does not change as a reaction to hand or gun movement. The collision volume vanishes when the gun is picked up again or the magazine is removed from the gun, at which point collision acts as expected. The static mesh follows the gun–not the hand–as expected even when the gun is dropped.

I ran out of space in the previous response, but wanted to share a link to my test project that contains the changes you recommended:

AttachTestV2.zip

After further testing I was able to get reproduce the clipping in the first video in your last response. If you use Set Collision Object Type on the magazine so that its default is physics body and that it only gets the new collision type after being attached (IgnoreGun) This will allow the gun to collide with the magazines on the table that are not attached to the gun. You will then need to set the collision object type back to physics body when the magazine is removed from the gun (example below).

Example:

][1]

As for the clipping through static objects (when the gun is placed up right on the table and the magazine clips through), this is a known issue that has been submitted to the developers for further consideration. I have provided a link below to the public tracker. Please feel free to use the link provided for future updates.

Link: Unreal Engine Issues and Bug Tracker (UE-30895)

Make it a great day

Thanks for the update regarding UE-30895. Knowing that bug is out there will spare me quite a bit of insanity for the time being. As far as changing collision, that looks straightforward enough. I’ll try it out in the test project once I have some free time, but otherwise I think your response addresses all my concerns. Thanks for taking the time to look into this!

Can you send me a copy of your zip file?I want to learn it deeply.Thank you!