• Advertisement
Sign in to follow this  

Unity Best way of volume selection

This topic is 1397 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi!

I'm writing a sandbox game in Unity 3D based on voxel terrain. I need the player to interact with the world (place/remove blocks).

 

The problem is, that size of the smallest voxel is 6 cm, so placing voxels one-by-one is unacceptable if player wants to build somehthing big. To solve this problem I've created a crafting system, which lets the player create e.g. a 40x5x5 cube of stone.

 

Now, the problem is that player must be able to change the orintation of the created item and I don't know how to achieve this! Do you have any idea how could reorientating look like? Maybe according to mouse movement (but how)? or using keyboard...

 

I've attached a screenshot of what it is like now. Please think of a way how could player reorientate that box in a user-friendly way.

 

Thanks.

Kiel368

Share this post


Link to post
Share on other sites
Advertisement

How about a two-click mechanism? The first click lets you drag a rectangle of blocks over the XZ-plane, the second click scales along the Y-axis. This allows the user to create any combination of blocks.

Share this post


Link to post
Share on other sites

You can allow selecting a single axis at a time and resizing/moving on that axis. These tasks can be done by pressing a key, scrolling the mouse wheel, clicking, dragging, whatever.

 

For rotation you usually have some hard to comprehend system where you can rotate using keys. The user then hits the keys randomly until the object ends up with the correct orientation. You can make this easier by having the keys be fixed to global axes (instead of tied to local object axes). You can also add indicators to tell which key rotates on what axis (hovering thing with the key shown for each axis).

 

You can also have rotation by dragging the object or some GUI surrounding the object with the mouse but you should also have the keyboard version because the mouse tends get slow and annoying after you become a pro.

 

And last, you can implement some automatic detection of optimal positioning based on surroundings, but make sure it doesnt get in the way and randomly change the positioning while the user is trying to manually adjust it.

Share this post


Link to post
Share on other sites

The game Cosmo Bots demonstrated a 2D version of what you're after. It could accurately figure out your intentions through a combination of mouse movement and ray-tracing (I think it would prefer to rotate towards the nearest wall). If you weren't happy with its orientation, you could right-click the mouse to manually rotate it.

 

I think the most intuitive method would be to rotate the volume on the 2D surface of the currently selected block, according to an average mouse direction. This would be done as follows:

  1. Determine the surface normal the mouse cursor is over. For instance, if the mouse is on the top side of a block, the normal would be [0,1,0], where as if the mouse were on the side of a block, the normal would be [1,0,0] etc.
  2. Calculate a normalised directional mouse movement vector in 3D. This could be done by storing, say, the last 30 3D mouse positions in a ring buffer, and calculating the difference between the first and last point.
  3. The normal from step 1) is the axis around which you should rotate the volume selection. Using the mouse direction, you are able to calculate an optimal angle for the volume selection. You'd of course round the angle to 90° steps.
  4. Make sure the volume doesn't intersect with any other blocks, adjust position and angle accordingly.

Does that make any sense? I can create some illustrative images with MineCraft if not...

Edited by TheComet

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
  • Advertisement
  • Popular Now

  • Advertisement
  • Similar Content

    • By Atwo Studios
       
      Hey guys,

      Anthony here from Atwo Studios bringing you some new updates for the new year!
      In this video I go over our game ROY, the new games and some general updates to the company!

      If you have not checked out ROY feel free to give it a try! Many people have said they enjoyed the game thus far!
      ROY: https://goo.gl/o6JJ5P
       
    • By Affgoo
      https://play.google.com/store/apps/details?id=com.NE.Alien
      still a lot of work to do, but its pretty stable  please let me know what you think <3
      Atlas Sentry is a game of destroy everything. Using your turret, simply swivel and shoot your way to victory, upgrading your weapons to unleash destruction on the variety of spaceships. The bigger your combo’s the more score you get! Earn silver as you play and then purchase new weapons and abilities to better deal with your enemy. Different enemies use different tactics and weapons, work out your own priorities in their destruction order. 

      Features: 
      **2 different game modes 
      **A level select mode with 20 difficult levels including a final boss, can you defeat it? **Arcade mode of endless destruction, how long will you last? 
      **High scores to compete against others, see who can take the top spot. 
       
    • By Chamferbox
      Chamferbox, a mini game asset store has just opened with some nice game assets, 
      Here you can find a free greek statue asset 

      Also check their dragon, zombie dragon and scorpion monster out:



      They're running the Grand Opening Sale, it's 30% off for all items, but for gamedev member, you can use this coupon code:
      GRANDOPEN
      to get 50% off prices What are you waiting for, go to
      http://chamferbox.com
      and get those models now!

      View full story
    • By Dafu
      FES Retro Game Framework is now available on the Unity Asset Store for your kind consideration!
      FES was born when I set out to start a retro pixel game project. I was looking around for an engine to try next. I tried a number of things, from GameMaker, to Fantasy Consoles, to MonoGame and Godot and then ended up back at Unity. Unity is just unbeatable in it's cross-platform support, and ease of deployment, but it sure as heck gets in the way of proper retro pixel games!
      So I poured over the Unity pipeline and found the lowest levels I could tie into and bring up a new retro game engine inside of Unity, but with a completely different source-code-only, classic game-loop retro blitting and bleeping API. Months of polishing and tweaking later I ended up with FES.
      Some FES features:
      Pixel perfect rendering RGB and Indexed color mode, with palette swapping support Primitive shape rendering, lines, rectangles, ellipses, pixels Multi-layered tilemaps with TMX file support Offscreen rendering Text rendering, with text alignment, overflow settings, and custom pixel font support Clipping Sound and Music APIs Simplified Input handling Wide pixel support (think Atari 2600) Post processing and transition effects, such as scanlines, screen wipes, screen shake, fade, pixelate and more Deploy to all Unity supported platforms I've put in lots of hours into a very detail documentation, you can flip through it here to get an better glimpse at the features and general overview: http://www.pixeltrollgames.com/fes/docs/index.html
      FES is carefully designed and well optimized (see live stress test demo below). Internally it uses batching, it chunks tilemaps, is careful about memory allocations, and tries to be smart about any heavy operations.
      Please have a quick look at the screenshots and live demos below and let me know what you think! I'd love to hear some opinions, feedback and questions!
      I hope I've tickled your retro feels!



      More images at: https://imgur.com/a/LFMAc
      Live demo feature reel: https://simmer.io/@Dafu/fes
      Live blitting stress test: https://simmer.io/@Dafu/fes-drawstress
      Unity Asset Store: https://www.assetstore.unity3d.com/#!/content/102064

      View full story
    • By DevdogUnity

      Ho ho ho
      Tis the season of Christmas surprises, and we have a awesome one for you! 🎅  
      Sponsored by all your favorite Unity Asset Store developers, Nordic Game Jam, Pocket Gamer Connects, and co-hosted by Game Analytics, we (Joris and I – Devdog) are launching the second edition of our yearly Christmas Giveaway Calendar for all Unity game developers!
      You can already now sign up right here.
       
      So what’s this all about?
      For the past weeks, we’ve been collecting sponsored gifts related to Unity (asset vouchers, product keys, conference tickets etc.), and throughout each day of December leading up to Christmas Day on the 25th, we will be sending out these sponsored gifts as early gamedev Christmas presents via e-mail to hundreds of lucky winners.
      The total prize pool is at $35,000, with over 1200 presents donated by the awesome sponsors!
       
      Merry Christmas from Devdog, Game Analytics, and every single one of the sponsors.

      View full story
  • Advertisement