Moving platform that "stops" when it hit something

Hi all,

I would like some help on how to create moving platform, than goes up 100 units.

However, if it would “hit” something it would stop, and then return back to it’s original position.

so if it was extend 49 units and hit something on the 50th unit. It would go back 50 units.

Ideally, it would also ignore the character if this is possible.

How would I make this?

Hi ShrewGlue,

I would like some help on how to create moving platform, than goes up 100 units.

Here you already known that you need a function in your “Platform_BP”. Will call it “Move”
There is simple calculations. You should get Actor Transform and adding +100 units in directions what you like, if you wish you can add to calculations “Lerp” or “Ease” to make smooth interpolation.

However, if it would “hit” something it would stop, and then return back to it’s original position.
so if it was extend 49 units and hit something on the 50th unit. It would go back 50 units.

To do this part i’ll recommend you to add Box Shape Component to your BP and then use it as Overlap Box. Generated Overlap Event will return to you Actors that Overlapping that box right now. "

Ideally, it would also ignore the character if this is possible.

Here you may set “Ignore Only Pawn” Collision Preset on your Box Shape Component in your “Platform_BP”. It will ignore player pawn and will not generated any events in this case.

Well, if i misunderstood you somewhere let me know, or you will have additional questions, let me know here

Best wishes,

Thanks for the help! I have two questions

  1. I’m stuck in an infinite loop here:

  1. Also how would (I’m now assuming the player can start the platform) I make the platform stop when a player on the platform collides with something overhead. Here is a picture

26673-collision.png

In this case if the player and platform are both going upwards, and the player collides with something overhead. The platform will return to it’s original poisiton

Another way you could do it would be with a matinee, like they do in this tutorial: [Unreal Engine 4 Tutorial - Trigger and Animate Elevator - YouTube] except only animate it one way (either going up or going down; doing both is unnecessary).

Make it so that when the platform is stepped on initially, it plays the matinee and activates a boolean that says that the platform is moving. Put a delay that lasts for the duration of the animation that turns the boolean off after it finishes. Then have it so that if the boolean is true, and the platform hits something, it activates the node “Change Play Direction.” This will stop the currently playing animation and make it turn around until it reaches its original position or hits another object.

Additionally, if your platform reaches the end without anything, you can use the “Reverse” node to play the animation to play it from the end back to the beginning.

It’s a lot less work in the blueprints. If you do it right, it’ll look something like this (but with your reverse play direction boolean in place):

To answer your second question (how would you do it if the player collides), you could use the OnActorHit command for the player’s character and have an event that changes the matinee play direction if the boolean is on.

Alright! And then if the hit direction is in the actor’s general “head” area I’ll reverse it.
How do I set it so that if the hit area is in the actor’s general head area (a capsule) then it tells it to reverse?

So, to make it so that when the hit direction is the actor’s general “head” area, you could edit the static mesh so that it has a collision box covering it and above it (at the player’s approximate height level) like so:

27231-box+trigger+static+mesh.png

Now you can make it so that if the platform is moving and it encounters a collision, the matinee will reverse. Make sure that in the static mesh’s collision options in the side panel in the level editor are set to “block all dynamic”. Now, I’m pretty sure this will make it so that the box collision above the platform will prevent the character from going through it, so you may want to put it above the main character’s head.

*Note: There’s an option under “collision” that lets you set it so that the collision detects everything except characters and pawns, which would be a better option, but I think that the player would fall through the floor if that option is used. I’m not quite sure, though, (matinee and collisions are not me forte) so try playing around with it.

Thank you! This is exactly what i need. last thing is that the platform wont always be moving up and down; I’ll be using the same Blueprint for the platform going left to right. So depending on if the platform is going vertically or horizontally, the distance between the collision box and the platform will need to be either the characters capsule height or the capsule diameter. How do i set this up?