Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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.

Product Version: UE 4.7
more ▼

asked May 22 '15 at 12:59 AM in Blueprint Scripting

avatar image

60 11 13 16

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.

more ▼

answered May 22 '15 at 03:19 AM

avatar image

617 21 16 35

avatar image namcap May 22 '15 at 03:50 AM

alt text

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)

avatar image PixelOmen May 22 '15 at 04:05 AM

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.

avatar image namcap May 22 '15 at 04:22 AM

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.

avatar image PixelOmen May 22 '15 at 04:28 AM

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.

avatar image namcap May 22 '15 at 04:35 AM

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.

avatar image PixelOmen May 22 '15 at 05:01 AM

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.

avatar image namcap May 22 '15 at 05:15 AM

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.

avatar image PixelOmen May 22 '15 at 05:25 AM

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?

avatar image namcap May 22 '15 at 05:41 AM

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!

avatar image PixelOmen May 22 '15 at 06:17 AM

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.

avatar image namcap May 23 '15 at 12:28 AM

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.

avatar image PixelOmen May 23 '15 at 02:44 AM

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.

avatar image PixelOmen May 24 '15 at 12:42 AM

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.

avatar image namcap May 24 '15 at 01:28 AM

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!

avatar image PixelOmen May 24 '15 at 01:31 AM

alt text

moveable.jpg (310.7 kB)
avatar image PixelOmen May 24 '15 at 01:39 AM

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.

template_2d.zip (2.3 MB)
avatar image namcap May 24 '15 at 01:46 AM

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!

avatar image PixelOmen May 24 '15 at 01:59 AM

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. alt text

avatar image namcap May 25 '15 at 12:36 AM

Well that's simple enough to do, thanks!

Also, I was messing around with what you sent me and then also made a new project with the starter content and I think I found out where the issue lies, but I don't understand it.

If I make the Movable Platform into a blueprint and properly do the collision settings (overlap WorldDynamic) and then drag in a regular Sprite block, then the "Attach Actor to Actor" works. But, if I then turn that Sprite block into a blueprint and drag an instance of the blueprint into my level, the block and the movable platform no longer interact and the movable platform just passes straight through the block. Do you know what's causing this to be a problem and if there's a way around this if I want to use blueprints?

avatar image PixelOmen May 25 '15 at 12:42 AM

Are you setting the block's collision channels to overlap as well?

avatar image namcap May 25 '15 at 01:05 AM

Just did that and it worked, so I guess blueprints weren't the issue.

I finally got it to work, though. I remade the platform and block from scratch (with PaperSprite as "self") and set all the collisions as you said, and it finally ended up working. I'm still not sure what was wrong with my old blueprints, but I'm just glad it finally works. Thank you so much, you helped me out a great deal!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question