Block Extrude similar to Infinifactory

Hi there,

I am trying to replicate as close as possible the behavior of drawing blocks from Infinifactory. At first I thought this would be a very straightforward task, but my implementation leads to a very unintuitive player experience.

Here is a video of Infinifactory for more context:

it seems like there is a stack of rules to apply when detecting toward which direction a single block can be “extruded”, I am trying to define as many of them as possible, so far these are what I can speculate:

  • faces are subdivided, these subdivision are detected when raycasting from the camera, and help define a direction of drawing?
  • camera direction?
  • maybe invisible planes?
  • maybe 2D space vs 3D space test?

The part that is the most mind boggling to me is at 6:50 in the video. The axis of extrusion can be completely switched from x to z and back while still pretty far from the starting position.

Such a simple mechanic that we take for granted hides way more complexity when picking at it.
Any help understanding it would be greatly appreciated.

Thanks

i’d maybe try some kind of “pick closest ray-direction, from box-axis-rays to mouse-ray intersection”

1 Like

Thanks @mgear , that’s already a good insight,

Do you reckon it would be the same system when you’re close to your starting cube and trying to draw from any direction at least one cube? (like for instance at the 2:10 mark in the video).

Also do you think rules are shifting depending on the camera view? Looking at my initial cube from different angle doesn’t seem to lead to consistent behavior… and yet it works fantastically well…

I bet there’s some sort of rule that the mouse-ray actually starts a short distance in front of the camera, so that it won’t “intersect” with potential block-positions that are very close to the viewpoint. But I’m only speculating.