How to snap a spawned actor to existing actor?

Hi man , its really not clear what you need , so here some thing that you can do.

You can spawn any actor in any place in the universe.
If you want to spawn at the center of the CharacterB you can get his location and spawn there.

The Character, and a lot of things have a center. The center may be not where you want to spawn.
So you have to add a handmade vector using the relative vectors like Forward and Up .
to make a vector to add to your spawn to put “the hat on his head”.

Unreal have a sistem of sockets.
You can for example, get the mesh of a character and add a socket to a bone.
So when you want to spawn the object in his hand… you can get the mesh reference, and search for his HAND-SOCKET… Get his transform to place the spawn exactly there.

Sure you need to attach the spawned actor to the socket or the actor or anything that moves.

You can also have around in the world some Actors or target that you can use to address your spawn.
Lets say you want to add a point light in the nearest lamp.
You can search for all actor lamp, check and store the nearest one with a loop , and then use the lamp location to spawn there a pointlight.

Sure you can use also an array to store the same informations.

In the editor you can move and snap the Actors and the meshes using the grid sistem, or the XYZ location in the details, or also snapping to the vertex, pressing and moving with the middlemouse.

Try to search for some info about these stuff…

Thanks for answer

Sorry its a little haotic post, ill try to explain further.

Spawning take place in a game, i have no problems using grid in editor.

Im spawnign a wall on the ground, with line trace from my camera and with vector extended so it spawn roughly 3 meters from my character.

What i want to do is when i select my next actor to spawn, it will snap to existing wall on the ground, either side to side (maiking it 2 times longer) or with rotation (making a building corner), depending on how i look at it.

I can already spawn another wall, and move it roughly in position, but theres always something off, like height or space between them. That wouldnt be that bad, except im worrying its going to mess my textures later.

Im familiar with attaching items to socket on a skeleton, like for example putting weapon into hand, or a hat on a head. But i didnt know i can put it on static actors. Im going to research that topic. Thanks for your help.

Edit 17-01-2016 15:49 GMT

I can attach actor to socket when spawning, but is there a way to get socket name thats closest to my character or better to other item?

When i look at actor, it checks for hit, and when present it spawns another actor on top (i only have one socket). Is there a way to get a reading of actors side or plane or something so i can spawn to relative socket on that plane.

/ Edit 17-01-2016 15:49 GMT

Could You guys point me in the right direction for building a base from predefined actors. I’d like to put a “magnetic” points on actor, so when i spawn an actor from my inventory it automatically snaps in the right position. Like joining walls together, basically building system from fallout 4.

I tried putting target points on the ground but thats not working out for me. Maybe if there was a way to put target point onto actor then i could figure something out.

I also tried to put colision boxes onto mesh, but when i spawned an actor next to it it didnt register.
Ive read something about pivot points, but im not that fmailiar with 3d modeling. Is there a way to add additional pivot point into actor, and if so how i should activate them to join?

Right now im spawning actors by running loop, its basically spawning and destroying actor, and it allows me to move and adjust position. when im happy with it i press LMB and actor is spawned indefinitally. I dont know if thats the best way though.

All answers appreciated. Thanks.

i just thought about a way to do it, does i make sense when in building mode to change movement and camera rotation to predefined values, like turn every 45 degres, move every 20 spaces, this way it should be easier to snap

or mathematically round up or down spawned actor world location? I dont want to do it worng way, and later have to add pivots or anything else to my models.

Hey, I found this solution for my self. This tool is comfortable to work. Look at Vertex Snapping! Learn more here

Hope this helps.