FirstPersonCharacter also moves if the location of the actor it is standing on changes

I am working on a game where the character (using FirstPersonCharacter) can grab boxes. I do a ray cast, and if I find a ‘Grabbable’ (an interface I added) I attach it to my character using Grab Component at Location with Rotation.

The way I have set it up is like this, whenever I ‘interact’ with the box, it is attached at a point at some distance in front of my character. That is working as intended.

However, if I am standing on the box that I am interacting with, then the box still moves correctly where it should (at some distance in front of my character) based on where I was standing, but then my character also moves on top of that box and then physics goes crazy and box and I both go flying.

What I tried: I thought it could be because while grabbing the box using that in-built function, the box might be trying to move through the character, so I tried 2 things but both did not work:

  1. Increase the distance in front of the character where the box should be attached. Now the box did move far, but the character was still standing on top of it and physics went bad.

  2. I thought even with the larger distance, the box might be trying to move through the character. So before attaching, I tried to set world location of the box. But as soon as I set world location of the box, my character also teleports with the box staying on top of it. And then after the grab attachment call, physics again goes weird (Tested this by adding delay between the two).

Not sure what I can try. While I was playing with some settings trying to fix it, my FirstPersonCharacter BP got corrupted, which was very difficult to find a solution for.

Edit 1: Also tried disabling Enable Physics Interaction in the Character Movement component.

I have found the solution. In the Character Movement component, there is a setting called Land Movement mode. The walking mode is what is causing the character to stick to the object it is on.

I made these changes:
When I start grabbing the object, set movement mode to “Custom”, then move the object to the location where it should be after grabbing, then change back the movement mode to “Walking”. After that, I call the Grab component function and set my internal state variables to show that I have grabbed the object so that now event Tick can update the Physics Handle location each frame.

Another change I made was to enable CCD when I start grabbing an object and disabling it again when I stop grabbing it. This made sure that the box is not going through the walls.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.