How to have an actor move another actor?

I’m creating a 2D game (no simulated physics) with automatically moving platforms and pushable blocks. I want to be able to push a block onto a platform, and when these objects hit or overlap, I want the platform to carry the block to the correct position and have the block stay at that location (so the block can be floating in space).

I’m not quite sure where to begin with this. I’ve tried attaching the platform to the block, but I couldn’t get that working. Any help would be greatly appreciated.

There’s a lot of different ways to approach this, but I’ll tell you what I would probably do off the top of my head. I’m assuming you’ve already created the mechanics for “pushing” the block. If so, then I’d say there’s 3 things to focus on here:

  1. When to start moving the platform.
  2. Attaching/detaching the block to/from the platform.
  3. Checking to see if the block has reached it’s destination.

1A. I would avoid using the platform itself as your overlap object. Unless you set a delay, the function tied to the overlap event is going to fire as soon as the edge of the block touches the edge of the platform, meaning the block won’t actually be on the platform yet. I would create a trigger box for the overlap event somewhere inside the platform so the block has to be pushed entirely onto the platform first. If not, I would add a delay like I said. It’s up to you.

2A. You can attach the block to the platform using an “Attach Actor to Actor” node. Under “Attach location type” select “keep world position”. There’s another node called “Detach Actor to Actor”, I’m sure you can guess what that does.

3A. I would probably just put another trigger box at the destination and call the Detach node from that overlap event.

In order to do the above you’ll need to know the basics of how OnActor/OnComponent overlap events work with their respective “other actor” pins, as well as how to cast references to blueprint classes. If not, that’s a different set of questions, but I can try and help you with that too if you don’t, just let me know.

Thanks for the response! I attached a picture of what I did, which isn’t much because I am not sure what to attach to “Target” and “In Parent Actor” for Attach Actor to Actor. I will most likely switch to your idea of using a trigger box since it seems to make more sense, but since I have not worked with those yet (I’ve just begun learning) I figured I would start with what I know more about. Once I know which pins to properly attach, I believe I can figure out the rest, since it seems fairly straightforward.

(TopCollision overlap is the collision for the platform, and the UpDownBlock is the pushable block)

I’m assuming this is the event graph of the platform blueprint? If so, you’ll want to attach the output of the cast node to the target and you want a “self” reference in the parent actor.

Edit: Also you might want to create a branch that checks to see if the class of the “Other Actor” matches the class of the Block blueprint. Otherwise it will use any actor that just so happens to overlap that trigger.

Yep, that’s the platform blueprint. I attached the cast node pin and the “self” reference to the “Attach Actor to Actor” and when I simulate the game and watch that blueprint, the nodes all seem to execute, but the platform goes straight through the block, without the block moving at all. Could this be caused by some wrong collision settings I have for one of the actors? Sorry that this is a different problem! Thank you for your help though, I greatly appreciate it.

Actually now that I think about it you don’t need to cast the block at all, just plug the other actor pin directly into target after the class check.

Oh, that makes sense. That helped me with my goal of expanding this to other blocks, thank you. I still have the issue of the platform going through the block, however. If I switch “keep world position” to “keep relative position” or “snap to target” then on contact with the block, some change occurs (the block scales, I’m not sure why). But if I use “keep world position” then the platform goes through the block with no change.

The collision responses can get a little tricky. Check what “Object Type” your block is, most likely WorldDynamic, and make sure that that object type is set to “overlap” on your platform’s object response channel. Also make sure both actors have “Generate Overlap Events” enabled.

I didn’t have “overlap” selected on my platform’s object response channel for WorldDynamic, so I set that. Sadly, it still doesn’t want to attach to the block. I’m not sure if it’s a collision that is going wrong, or some way that “Attach Actor to Actor” works, because if I switch that node out, for say “Set Actor Location,” once the block overlaps the platform, its location is moved as specified. Sorry for having such a long problem.

Hmm. Interesting. I just tried it on my end and it worked. How big is your project, minus the starter content? Maybe you could upload it somewhere and send it to me?

Moving Platform BP

UpDownBlock BP

I couldn’t find a place to upload my project that would accept its size, so I just uploaded the two blueprints that have actors which are overlapping. Hopefully that’s enough for you to see what I’m doing wrong. Thank you for your help!

I can’t open or import uassets unfortunately. I guess you can take a screen shot instead. Try to get the event graph along with the components and their collision settings.

Sorry for the late response, had to travel, but here’s the album of images, if you need any other images, I’ll obviously be glad to provide them.

The last image shows the overlap that occurs (when the actors should be attaching). The other images show the entirety of the blocks’ event graphs and their collision settings. I selected “TopCollision” for the last image to show those collision settings, and selected “PaperSprite” for movable platform for the others.

Oh right, its a sprite based side scroller, that probably changes things. I tested it out on a a 3D side scroller. I’ll have to test it out with sprites.

I tried all of that, but sadly to no avail (although, I’m not sure how to make the instances of these actors movable, I can only find that option in the blueprints).

If you did your test in a new project, would you be able to send me that project so I can compare everything you did to what I did? I’ve tried making new brand new blueprints and starting from scratch, but nothing seems to work. I guess I’m missing something but I really can’t find out what that is. Thanks for your incredible patience and help so far!

I just tried it, it should be the same. I’ve thought of a couple other things you can check though.

Make sure the block is set to overlap dynamic.

Check the collision settings of the instances in your level. If the blueprint already existed in the level when you changed it, any instances that were already in the level will probably retain their original collision settings.

You can either change them manually or delete them and bring them back in. Also, make sure everything is set to movable, both in the instances themselves and the blueprints.

link text

I’m setting the overlap event via the level blueprint in this project, but that shouldn’t matter.

Make sure to add the starter content to the content folder before you open it.

I just tried it with a basic actor class and it still works, but FYI if you want to create a blueprint with a sprite as the parent class, you just select as it as the parent class when you’re first creating the blueprint.

I think I might see what the issue is. I don’t have those settings available to me in the level since my “uppermost” (parent?) component is just a basic “Actor” whereas yours seems to be a PaperSprite. My component under the “self” actor is a PaperSprite, but the “self” actor itself is not. How do I make a blueprint where the “self” actor is a PaperSprite?

EDIT: Didn’t see your second post. I’ll try out that project now, thanks!