Drop object against wall

Hello.

I am doing a game and I need to grab and drop objects. The grab method is done: I attach the object to my character and I can move freely for the map with it.

The problem is to drop the object. To drop the object, I simply detach the object and teleport to a point in front of the character. But when I am in front of a wall, the object places in the wall. I dont know how can I detect when the object is in the wall and move it to me at a position that doesnt exist collision.

I see videos of The Talos Principle and they do that, when you try to drop an object near a wall, the object puts in a free position and moves the player back.

Thanks for your time!

you’re using “teleport”, the teleport node returns a boolean, true if it could teleport and false if it couldn’t, use a branch and if it’s false then try to teleport to somewhere else, you can also use “SetActorLocation” instead of teleport and check the “Sweep” option, it will try to teleport to the dest location but let’s say it stop moving if it find something in the way, so it will teleport the actor to just before the collision happens.

The correct way to do this is by doing a raycast / line trace from it’s current location to the target.

You need to do a line trace forward (with the length of your maximum drop distance + object size / 2 so you know that even when putting it down, it will not be placed half way into a wall in edge cases where the player is barely far enough away).

If you just sweep the player can place objects behind a wall if he is close to it and the wall is rather thin (because the sweep will not find anything wrong with the location. It just cares about whether or not the place is occupied. With the trace you can detect if there’s something in between. If so you can calculate the size of your object, reduce it from the hit location and place it accordingly.

Hello, in my opinion you should use the Pick Up Physics Object. There some tutorial for this. but the 1st in google search is one from epic. A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums
Cheer. Hope it help.