Stop my platform from moving through other objects

Hi all, i’m kind of at a loss here.

I have a very simple setup in which i use levers to move a platform around.

Unfortunately if the platform touches a wall or any other mesh it goes right through it.
And i want this to stop from happening. I want to be able to use the levers to control the movement of the platform. The moment it hits a wall the platform should stop and i need to push the lever the other way in order to move the platform around again.

I thought collision would take care of this but unfortunately it doesnt work. But maybe thats because using the actor offset function overrides the collision?

My character CAN stand on the platform while its moving around so there is atleast some sort of collision going on.

I tried different kinds of collision setups with no luck.

I sort of got a overlap begin/end to work. Where i would set the actor local offset to 0 the moment it overlaps, But since it wont be able to end the overlap, this doesnt seem like an sollution either. I didnt get a hit event to work either.

I feel like there must be a very simple solution but im not that great with blueprints.

Any help is greatly appreciated.

This happens because you have no distinct direct location for the platform to go. Do you know the use of vectors in UE5? It uses 3 dimensions of floating values which you can use as a coordinate in 3d games.

The idea is to hardcode the vector target location via instances or computing the travel distance. You can set it as an instance editable variable which can adapt to the environment and liking. Then simply set the actor to move to the location, and set it back to the original location so it will return back to the initial location once the next target location has been reached.

Another way is to use the traces to check for collision. If it hits something then stop and execute the return back to the original location function. There must be something you missed with your setup, but you can also just stop it once it begins to overlap.

How does that solve/create collision checks?

  • (I have a dumb moving platform that is set to move to a vector. But that doesnt make it perform collision checks.)

This seems like the actual solution. But do you have an example picture or tutorial link?

Option 2: Would there be a benefit of making the platform an AI character - thus it can use NavMesh/AI move nodes (which have Does Path exist/ collision checks)?

  • Con: Im thinking that the AI would need a Capsule collision (to use Movement Component & thus NavMesh), which is round - hard to stand on.

  • But would that be fixed by adding another cube collision over the Capsule - thus create a flat platform to stand on?

  • Pro: I think it would solve pathfinding/collision.

You don’t. Cause, it is meant to be hard coded. Simply move to the target location and return back. Since you hardcoded the coordinates, it won’t collide with the environments. Also, the player can still interact with it as long as you enable the collision.

This seems like the actual solution. But do you have an example picture or tutorial link?

Did you face anything wrong with just adding the box collision and letting it overlap? They should trigger the overlap event normally. Unless you didn’t tell me something.

So you mean hardcode as in you know where obstacle meshes will be at Location 1 and 2, and thus make the Platform NOT move that far (into obstacles).

  • I thought of his question in terms of procedural levels, or as he said where it’s a puzzle and Player can manually move obstacles while in game - until the path is clear for Platform to move/reach goal (without going inside obstacle meshes = the problem).
    ** Thus he cannot pre-calculate and hardcode exact stopping Vectors for the movement. He needs smart detection. Thus I gave my idea of making Platform an AI > so it can use NavMesh to perform path collision checks.

I’m not OP, but I agree with his question (and I’m not at my project right now to test). Thus I asked if you have a visual or video to show how to set this up? Ty.

This sounds like a constant distance/location to me, at least. Using AI could solve it, but a complex algorithm like AI isn’t necessary for this simple functionality.

Hi all,

thank you for the replies.

Unfortunately i want complete control over where the platform goes. as the player will be standing on it while using the levers and control the platform to move around the world.

I had this setup before which does make the platform stop when it hits something.

But since its still overlapping when it stops i wont be able to trigger the end overlap event.

If you want fine control over where the platform goes, your best bet would probbaly be to move it along splines. Then you can define the path in the map editor so they won’t go through walls.

The idea pointed out by illspiritx of utilising the spline is a great idea. You can give it a try as it gives the target points to be dynamic.

Unfortunately i want complete control over where the platform goes. as the player will be standing on it while using the levers and control the platform to move around the world.

Which one is it you are pointing to? Problem with the end overlap event or begin overlap event? Or both? Also, you said, “But since its still overlapping when it stops i wont be able to trigger the end overlap event.” I’m still confused. Why do you want it to move when it is still overlapping?

Can you show us the code for your Player input that is fed into your Event Interact Move? (so I can reproduce a test)

I think you need to add a bool /collision check for each Cardinal direction. Meaning if Player presses W (move platform +Y), but it hits something - then disable movement only for +Y, but still allow Player to press D (move platform +X).
And have this collision check on a Tick, so it keeps updating: did we hit something? Yes, so stop input in that direction. But a second later, are we still hitting something? No, so allow that movement-direction again.

And I think you should setup movement-direction points, like this vid, but setup Cardinal direction points like my image.

So in his vid, you set Point 0 at the Center of your mesh.

  • Set the point North of your mesh (from top view = +Y axis) as Point 1.
  • Set the East (right) point as Point 2. Then add the rest, going clockwise.
    ** PS set these points internally in your BP, by using Arrows. Move them to 1000 units away from Point 0. Then in your code, drag in each Arrow component > Get location/vector.

So if player presses W, your code gets Point 1 as:

[Get current location of Point 0, which is inside the BP of your Platform mesh] + add [X = 0, Y = 10000]

(because we only want to change the Y axis location, so put X change as 0, and Y change as very far away from Point 0)

= new destination point to move to. (And it keeps moving in that direction until Player changes Input, or hits something.)

Then in your Event for On Component Begin overlap (we hit something):

Now set Point 1 (north point) = Point 0. This means we cannot move North anymore because delta: [Point 0 to 1] is no change on the Y axis.
But we can still move on the X axis (if we press D or A).

  • So have the collision code check which direction you were moving, and have 4 branches for each direction. If it was North, have code on that Branch > disable more North movement by setting that Point 1 to the same Vector of Point 0 (center of the object).

  • If we hit something going East (Point 2), set Point 2 as [the object’s current Point 0], so no more East movement.

  • Then have your Tick update/refresh Point 1 and 2 back to far away from Point 0 - to perform the check again.

Edit: also I believe your movement node is wrong. Use Set Actor location, not offset.

Hi,

Just make sure the component with the collision is the root and set Sweep to true:
Sweep

It’s in the fine print:


The BP:

Hope it helps.

Here is a test setup [v2] of my idea:

  • The movement key-direction works: Step on the platform > in the center > light turns green >
    ** Press E > and any WASD key (while in the center box) > and the platform will move [in the Cardinal direction of the last Directional-key pressed].
    ** Press W and it moves North (each time you press E)
    ** Press D and it moves East (each time you press E again)

  • TODO: add the collision check-stop

  • @pezzott1 Sweep didn’t work for me, maybe you can improve my code. But in this test I didnt set the Platform mesh as the root, because then I’d have to fix the scales of children.

  • But I’m posting now in case @beekder didn’t understand what I meant - get you started.

They are auto resizing the PNG 1 below, and converting to JPG. So DL the asset to see the code details.


Use_MOVER_BP9.uasset (373.5 KB)

I prefer another way of going at this.

For example:

2 Likes

Lol GJ. Looks cooler in UE5.
Can you post the asset?

Thank you all for the great replies. I’ll have to check it all out when i get home later today.

@pezzott1 I really hope it’s gonna be as simple as setting sweep to true.
I also find your other solution very interesting. i didnt even thought about possessing the lever.
Right now i have a check if i can interact with the levers and then just stop the character movement and rotation. Use the mouse to move the lever left to right or up and down, and translate the rotational angles of the levers to the movement of the platform.

I see if i can post an example of my setup with a video later as well.

Hi all, Well i finally got it to work. It really was as easy as setting sweep to true

thnx! @pezzott1

as promised here is my setup of the levers for anyone interested.

also a video of the platform in action.

There is however a small hickup in the camera the moment i collide with something at high speed but i think it has something to do with the ignore move/look input. @pezzott1 i think i’m gonna give your setup with possesion a try and see if that removes the hickup.

Looks good.

You’re in UE5x? For me that setting did not work in 4.27 (because then it also disables when player stands on the platform).

@pezzott1 can you post the asset files for your version? I cant see all of the graph. Thanks.

Yes i’m using UE 5.1.

I had something similar happening to me. You could try to adjust the collision settings on your platform to not to collide with pawns.

these are the settings i used (i have a spherical collision around my platform so i had to ignore camera as well, including the levers

Thanks @beekder. But did you also do this step to get yours to work?

I did not because I like to make my BPs interchangeable with different sized meshes. Which means I have to adjust scale. Thus if my Root is scale 0.8 (size of a different mesh), but I change the mesh, then I have to rescale the children.

This looks so cool!

If you still need control of your character, then pehaps making the platform a pawn is not really necesary unless the platform does need to listen to inputs.

Note that (I think) sweep does not work with rotation, only with movement. So the alternatives would be to use a sphere collision as root or do everything with physics.


Carrying a pawn will probably cause problems with sweep enabled. So that’s when you need to be creative and attach the character to the platform while ignoring collision, among other things to keep sweep on. So if someone has a better way then please feel free.

Attach is a quick test with carrying a character, though its using the movement component, not add location + platform used above.

PawnPlatform.zip (1.5 MB)

1 Like