Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Block Extrude similar to Infinifactory

Discussion in 'Scripting' started by tr0ma, Apr 8, 2021.

  1. tr0ma

    tr0ma

    Joined:
    Dec 4, 2012
    Posts:
    19
    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
     
    Last edited: Apr 8, 2021
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,350
    i'd maybe try some kind of "pick closest ray-direction, from box-axis-rays to mouse-ray intersection"

    upload_2021-4-8_21-11-15.png
     
    Antistone likes this.
  3. tr0ma

    tr0ma

    Joined:
    Dec 4, 2012
    Posts:
    19
    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...
     
  4. Antistone

    Antistone

    Joined:
    Feb 22, 2014
    Posts:
    2,836
    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.