I need help on how to snap or align instance mesh together by using the normal hit and instance orientation. any suggestions?
If you put the pivot point of the tetrahedron at bottom center, all you have to do is put it on the hit point. Same with the cube, actually, no offset.
Does it makes sense?
Wow, that is very good advice! I actually did that in Blender and never thought of doing so in Unreal
Now how can I get the right orientation?
Well, you have the normal, of course. But as for the rotation, I think that would be MakeRotFromZ, from the normal ( or maybe MakeRotFromX ), possibly plus some constant.
I set my mesh like that in Blender:
and Apply that on hit detection:
Unfortunately, I’m getting this
Getting close
Admittedly, I don’t get something great, but it fits a bit better than that
Is the collision the right shape?
I can get it on the face, fine. The problem is a) rotating to fit and b) putting it in the face center.
Mmmm, might be something to do with the mesh being instanced.
Two things I’m wondering
-
Are you hitting the instance?
-
The stuff coming back from the line trace is world, I think the AddInstance node is relative.
Last idea…
I think it’s much easier to get the position right if you’re connecting to a blueprint. You can put scene components in with the correct transforms etc.
So, when the trace hits a mesh, you can spawn a blueprint with the same transform and see which possible connection point you’re closest to, then add the instance and remove the blueprint again.
Much easier than fiddly vector maths…
Yes, I got the same issue, i.e. I get the face right but not centered and rotation is not fit to the face.
Note: The collision to fit the mesh and yes I do hit an existing instance.
For the idea of using a Blueprint, I can’t afford that for VR since I want to spawn thousand of instances. If I do that with blueprint it will kill my FPS.
The BP is only there to make the connection, then it gets destroyed again. Tell me if you’re interested, and I’ll set one up…
Scratch that. I just fiddled with the concept. It would work with the cube, but not so easy with the pyramid, because the problem then becomes putting the mount points in the right place!
I have a theory, about having the pivot in the center of the mass, and the mounted pyramids can then use ‘look at rotation’ to position themselves in the center of the face… thinking…
Ok, if the pivot is back in the mesh center ( sorry ), this puts the spawned mesh on the center of the face
But the subsequent local Z is still wrong…
yes!! you are a genius! I just realized what you were talking about with the temp blueprint connector this morning after a good coffee and I now I found your details answer, great! haha!
I didn’t use the BP concept in the end. Yes, this is a BP, but only so I could number the faces to see what was going on
This will work fine with a mesh.
BTW, don’t ask me to explain that whacko vector assignment…
Yes! that works with the rotation and Normal. I had to adjust the normal to make it a negative value. I assume I mess up something with Blender export.
No I will try to make it works for other geometrical shapes
Same concept should work