I can see why there is a lot of complaints about animation not working after forcing the character collision. This is because he’s bound the action to Event Tick which means it will run every frame regardless of whether the character has come into contact with an object or not. This is going to cause a lot of problems!
All you need to do is use the Event ActorBeginOverlap and tie only 1 MoveUpdatedComponent to it. There’s no need for 2, he needed a secondary 1 due to the bug he already started by using Event Tick. Event ActorBeginOverlap is used when 2 actors bump into each other. The code will simply look like this:
It’s not perfect though, it moves the character well but it still looks like the 2 actors are overlapping each other as it’s being pushed so I’m not yet sure how to resolve that.
I’ve tried using Event ActorBeginOverlap but it doesn’t seem to work in this case. This event triggers only one frame until the pawn “exits” another actor and doesn’t solve the problem of pushing pawn. In my testing, it also only triggers when actors actually overlap (overlap behavior is defined as Collision Presets in mesh component) and by default, it’s pushing instead of overlapping.
If we are using Event Tick the pawn is going to be checked and pushed every frame thus solving the problem
I feel like you’re missing something in your explanation as I did exactly this, but I’m not getting any smooth movement
It doesn’t even seem to generate overlap events in response, I have both the pushing cubes and the player set up to generate overlap events, so I’m not entirely sure what’s going on here
This doesn’t fix the smooth movement, it makes sure the character gets pushed by the cube. I haven’t figured out the problem with smooth movement but I do see that it’s only smooth if the character is not moving. If the character is moving, it’ll clash with the cube.
Just make sure you are getting pushed by the cube, if not. Check your code or post it here for review.
Yes, I did mention that in the original post at the bottom. It wasn’t designed to either. It will fix the all the animation issues that occur when it’s assigned to event tick. Tick runs every frame and the character is not being pushed every frame so that’s why it’s a bad choice.
NB: The “sweep” feature only applies to the root component, so remember to replace the default root with the cube, or with a collision mesh
NB2: I think his code might be a bit more complicated than necessary. The distance/direction/delta seems overcomplicated. A simple hit.GetActor()->AddActorWorldOffset(hit.TraceEnd - hit.TraceStart); should be enough since the platform is being moved in the same direction as its velocity.
Thank you I was having this problem and it fixed my character moving properly again thought i did something wrong but i apparently didnt. Now the problem i am having is it is very glitchy when the character impacts with the object i dont think it is my laptop but it could be I have a maingear nvidia 3080 laptop with a ryzen 9
Hi, just so you know, the BeginOverlap event won’t ever emit, because the collision is set to block and not overlap. You can test it by adding a print String node at the end.
Actually, there’s a property called “Generate Overlap Events” and as long as that’s enabled, Overlap events will always trigger regardless of collision.
I’ve checked that box on the player character (it’s not present on the platforms) and it’s not emmiting the events when the collision is in block mode.
I’ve also added a collision box to my BP_PushingCube that is minimally larger than the original cube, and has collision set to overlap on actor and ignore on everything else.
@Wojte, just tried your way, and outside of it taking a second to figure out how to make the custom event boolean, it works like a charm. Only issue I’m able to find is that there is a small amount of drift to the left (while facing block) while beign pushed. This seems to be relative to push direction, so it’s always left while being pushed backwards. Any idea what might be causing this?
Other than that, want to reiterate, works splendidly and doesn’t break animations.
[EDIT] I just realized my cube was being moved on the X axis as well as the Y, without being rotated accordingly. So it was actually the cube moving left, not my character . Your solution has no issues.
I used @Wojtek screenshot as the basis but was able to use the video solution with a minor include for Get Actor Rotation. This fixed the character not rotating when using the video’s solution. I’m using Unreal Engine 5.1.