How to make snapping in a non-grid building system? Thanks
If there’s no grid, than what does it snap to?
Another object, snapping two houses with different sizes in a building system for example.
He might be able to refer to modular build system used, for example, in… No Man’s Sky, Conan Exiles, Fortnight and so on. Oh. Right. Also Satisfactory.
In general you try to detect which snap point the player is pointing at and move the object to that location.
Basically, in case of snapping, you keep track of two things:
You track where the floating ghost object would be if there were no snapping.
And you track nearest snap point.
When the user no longer looks at snapping point or looks sufficiently far away, your ghost object moves back to the “unsnapped” position. And when you move it around, you move the that position.
Object movement couldb e drag and drop or anything else.
I’d come-up with a snap radius, as in- the “ghost object” needs to be at least this close to another object to snap to that object. Do a OverlapSphere to find any snap-to objects that are in the radius. Then loop through them to compare the distances to find the closest one.
The above method requires snap-to objects to have colliders, though. Without colliders you’d just need a way to find out which snap points are close, or you could just loop through them all, depending on how many there are.
You need to check satisfactory build system.
Games like Satisfactory appear to use a wide spherecast or raycast to detect attachment points and snap to whatever is closest to the mouse cursor regardless of distance to the target. Once in snap position you may be able tro alter which part snaps using some sort of keys. So you do not bring the ghost close to the snap point, you look at it. This allows player to construct bridges while standing still and just moving mouse around a bit.
The snap points themselves are likely invisible floating spheres, what’s more they might be weighted based on current orientation of unsnapped ghost, that’s because a single piece can have a fairly large number of attachmet points.
In system you describe instead of just using a mouse the player will have to WSAD around the scene to combine the objects.