Download

How to put a box on top of another box(es)??? (Snap to Z)

I know it’s sounds very easy but it isn’t!!!

Hi there, I’m making a drag and drop puzzle and I need some light on how to do this: I did a drag and drop mechanics follwiong this tutorial Blueprint Actor Setup | Unreal Engine Documentation

and now I have a movable box, I need some way to snap this box to Z when I dragging it and it finds another box on the way. I know it’s pretty easy but I’m not having the right idea. any help please? I tried make this work on 2 ways, the first, I get the Z of the mouse hit location, but then the box keeps updating the z value and keeps coming closer to the pawn/ camera
z1.PNG
the second, I get the Z from where the player controler is pointing


then, the box keeps floating intead of being snaped to the ground, and the second box doesn’t get on top of the first one
z2eg.PNG
I tried some math formulas using the 2 Z values, but the results I get is the same result of the first image (the box keeps updating the Z value), or then, I can get a box on top of another, but with space between them.
I tried doing this suggestion “Try doing a line trace from your box down on the Z axis. Break the Hit Result and get the hit location, then set the boxes location to the hit location. You’ll have to play around with the numbers to get an exact result but this should work for what you are trying to do.”, I followed some tutorials as found in here:
https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/UseRaycasts/Blueprints/index.html But I can’t get this thing working
Please help, I’m 2 weeks trying to get this thing done now. Please help, show some BP examples if possible, thanks

Just do the line trace, what is wrong with it? Just do a line trace from the current box location to the box location -500 z. Set the box location to the hit location + the box actor bounds.

I don’tknow what is wrong. The ox have to be with phisics on when I’m dragging it? If you can get this working, please show some blueprint example. I just need these boxes to be put on the top of others to get this phase done.

Something like this you said?

Anyone? Please help