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.
asked May 22 '15 at 12:59 AM in Blueprint Scripting
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:
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.
answered May 22 '15 at 03:19 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here