Another Question about collision not working

Hi everyone,

First time posting here because I have gotten pretty desperate. I’m just trying to build your basic block breaker game and the player paddle moves right through the arch that’s supposed to limit the play area.

It does the same thing on the right side and it will pass all the way through the arch. I have rewritten the two C++ classes several times according to what I’ve read in tutorials and such and I’ve tried to make it as narrowly written as possible.

240627-paddlecpp.png

240630-archcpp.png

I’ve made sure that the two classes, a WorldStatic and a Pawn, are set to Block each other. I’ve made sure that the two meshes have collision geometry. (The Paddle mesh lists WorldStatic as its profile, but on the pawn itself, I’m telling it to use Pawn).

I’m not using any custom collision channels and I’m not using tracing, strictly the presets BlockAll and Pawn. I have tried using a separate capsule component on the paddle strictly to handle the collision, set it as the root component, and it still passes right through the arch. Clearly, I am missing something basic here and I’ve read so many different solutions to problems I do not have, I’m afraid I’ve just become blind to what I’m actually doing wrong. I haven’t yet tried writing out any collision functions for these classes that programmatically stops the paddle, because when I did the same thing on another project it didn’t work either and no tutorial I’ve seen has said anything about having to do this. Everything suggests that the actual blocking functionality is handled in the engine once the collision settings are set to blocked. While I wait for an answer, I will be trying this again anyway, but I wanted to get the ball rolling on this, since I’ve followed three different tutorials this month, following the specific instructions, including the Epic Live Training sessions with Tanks Vs. Zombies, and not once have I ever gotten the collision to work. Not once. Can anyone see how I am screwing this up?

Thanks for the help!

What comes to mind initially:

Use only simple collisions. Complex can get unpredictable.

Turn on CCD. Continuous Collision Detection will prevent things from passing through each other when they’re moving fast (although I’ve seen it happen when things aren’t going very fast at all).

Other than that, I’ve had a few times where it worked better when I used a collision component as the root and turned off collision in the mesh.

I added a capsule component as the root of the paddle, set it to use simple collision as complex, set the capsule component to the pawn preset. I brought in wall meshes from the Starter content package as well as bringing in BSP Geometry in the editor, placed them on either side of the paddle, and the paddle still slips right on through. I know I am missing something basic here, but I cannot see it and it is incredibly frustrating.

Using a player controller. Pretty much cut and pasted from when I did the Tanks Vs. Zombie Unreal Live Training.

How are you moving the pawn?

I mean are you using physics (“AddImpulse” and such), using a movement component’s “AddInput” (or whatever), or changing the location yourself?

That might be the problem. I’m by far no expert but I have found that when you set location it doesn’t consider collisions so you will zoom right through it. There is an optional parameter to sweep movement that should prevent moving through collisions. You still might need to prevent movement beyond a certain point though. To turn sweep on, just make it SetActorLocation(Pos, true).

That may be good enough but if not I think you’ll need to move the pawn as a physics actor (using AddImpulse() in most cases).

Another option is to use overlaps. When you get an overlap event on one side or the other, you stop moving in that direction. It’s also a good idea to set the location to the exact end because the overlap may not come in right away and the paddle will be a bit past the end.

If I understand you right, I’m using movement components reading in input via axis bindings, pushed through a struct as a buffer, then applied during tick().

Struct declaration ahead of Paddle Class declaration

240738-movementheader.png

PaddleInput as a member of the Paddle Class

240739-paddleheader.png

PaddleInput’s movement function

Setting up MovementCompenent and Tick function that actually moves the paddle

If you want, I can just try and post the code for the two files if that’s easier than snapshots here or there.

I really appreciate your help by the way.

Jin_VE, you wonderful, wonderful anonymous internet person! It was the sweep parameter, all right. And now it works! I cannot thank you enough. This has been absolutely maddening and it’s been driving me insane for literally a month. If we all get uploaded into machine consciousness’s in the Singularity, I’m going to buy you the digital libation of your choice. Thank you so much for your help.

Hehe no problem. Glad it wasn’t something else and I didn’t have you running in circles.