• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by ashjack · Jan 29, 2014 at 07:24 PM · c#javascriptcustomvoxel

Voxel Engine Coding Blocks?

Hi. I have recently got a voxel engine that I found on YouTube(Here) and I have worked out how to add blocks, and generate them in the world, but I didn't know how I would go about coding a block to do something. In this case, I would like to add a furnace that has a GUI, and the front texture changes when something is in it. I don't want a whole piece of code or anything, but snippets or pointers in the right direction would be a great help.

Thanks

AshJack.

Comment
JakubNei
Nicolaj Schweitz

People who like this

0 Show 10
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image HuskyPanda213 · Jan 29, 2014 at 07:57 PM 0
Share

Make the furnace gui on the player, and then activate it with SendMessage, this will greatly optimize and reduce bugs.

I'm guessing you will use First Person, use raycasts sent from the player instead of OnMouseDown(), I found that OnMouseDown does not work with the FirstPerson.

Make it that when the RayCast hit is there, there is a furnace tag as the hit's collider tag, and if Input Mouse1 is clicked, the gui is active on the player, then give a Ienumarator, that times the furnace glow, by using sendmessage to a void on the furnace, and then the sentmessage-void triggerss the Ienum.

I hope that helps!

avatar image ashjack · Jan 29, 2014 at 08:11 PM 0
Share

Thanks for the reply. How do you think is best to create the GUI? By script or by GUITexture? Also, I have looked at the scene while the game is in play, and the game registers the chunks only, not each individual block, so I don't know how to make the furnace an exception to this rule.

avatar image HuskyPanda213 · Jan 30, 2014 at 04:08 PM 0
Share

I would make a general GUI Script. It contains the furnace, crafting and other ui and it would be on the player(rendering too much gui is not good, even if you cannot see it!).

Use sendmessage to activate it.

Also I know that chunks are how the world generates, but user-placed blocks are not chunks, right?

avatar image ashjack · Jan 30, 2014 at 04:35 PM 0
Share

Annoyingly, I thought that too, but a user placed block is added directly to the chunk. Thanks for the advice on GUI.

avatar image ashjack · Jan 30, 2014 at 04:59 PM 0
Share

I have found a file called Blocks.cs, and it registers some types of blocks, could I use this to find the furnace (It is called fireplace in the code):

 using UnityEngine;
 using System.Collections;
 
 public class Blocks {
 
     public const string Dirt = "Dirt", Grass = "Grass", Snow = "Snow";
     public const string Sand = "Sand", Stone = "Stone";
     public const string Water = "Water", Ice = "Ice", Fire = "Fire";
     
     public const string Wood = "Wood", Leaves = "Leaves";
     public const string Cactus = "Cactus", Pumpkin = "Pumpkin", Flower = "Flower", Fungus = "Fungus";
     
     public const string Bricks = "Bricks", TNT = "TNT", Fireplace = "Fireplace"; 
     
 }
   
Show more comments

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

21 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Converting a javascript to C# 2 Answers

Distribute terrain in zones 3 Answers

press e to speek -1 Answers

Need help converting Javascript to C# 3 Answers

Snow based questions 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges