[Help] Spawning actor on exact surface of another actor from a line trace

Hi. I’m trying to make a system to spawn a selected actor on the surface of the object that was just clicked using a line trace. The blueprint(s) for handling all of this is really messy and strewn about because I have code for other tools and systems there but the way I’m doing it currently is doing a line trace for objects from the camera, getting the hit location of the line trace, and spawning an actor at that location. Considering most of the actors I’m using have the center at the actual static mesh center, doing this would spawn it inside whatever i clicked on because the line trace is on the surface of the object. I added offsets that are specific vectors to enter in that it adds to the transform when the model is spawned to try and remedy this. This solves the problem when the model is being placed directly on the ground, but is messy and doesn’t solve the issue when the model is being placed on a wall or the ceiling of something.
My question is: How could I spawn an actor so that it is placed perfectly on the surface of the hit actor from the line trace, at the impact point?
Here’s a basic example of what I want to do in graphical form:

(Red = Line trace, Green = Spawned actor w/ mesh)

If you need additional info, feel free to ask, I only refrain from sending blueprint code screenshots because it’s quite a wild mess at the moment.

When you spawn the cubes they are ‘arriving’ on at the spawn point in accordance with their pivot point. The default pivot point for the cube is the center, that’s why you get this.

If you want them to be ‘on the edge’ you need to make a copy of the cube which has it’s pivot point at the bottom center face.

Many ways to do this:

  1. Move the pivot point of the cube:
    HTF do I? Change Pivot on Mesh in Unreal Engine 4 ( UE4 ) - YouTube

  2. Put the mesh in a BP and make sure the center of the BP is where you want it to spawn ( bit too fiddly to explain unless you really want to do it this way ).

  3. Got a copy of Pivot Tool:

Why couldn’t you adjust the spawn position of the item you are going to spawn by half of the object to spawn’s width or height depending on what side it will collide with?

This is assuming you keep the object’s pivot in the center of the object. You would need to adjust this based on where the pivot is at, such as the feel for a character or enemy for example.