• 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 /
  • Help Room /
avatar image
0
Question by J.E.N.S. · Nov 05, 2015 at 09:12 PM · crafting

How do i make a crafting table

I've been seeing how to make a crafting recipe but not how to make a crafting table please help.

Comment
Add comment · Show 4
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 HenryStrattonFW · Nov 06, 2015 at 12:14 PM 0
Share

This question is far too vague to be answered, please specify exactly what it is you want help with, creating an object for the "table" in the scene, interacting with it to trigger the recipe UI, or the recipe UI itself.

avatar image J.E.N.S. · Nov 08, 2015 at 10:14 PM 0
Share

no i just want to now how to make the table and do crafting with it

avatar image HenryStrattonFW J.E.N.S. · Nov 09, 2015 at 10:23 AM 0
Share

Please submit this sort of post as a reply ins$$anonymous$$d of a new answer. Also your question is still far to vague to be answered. "how to make the table and do crafting with it" Is not specific enough to get reasonable answers that will be of use. You need to break the problem down into smaller parts and work out which specific smaller part it is you need to tackle first.

avatar image J.E.N.S. J.E.N.S. · Nov 11, 2015 at 10:06 PM 0
Share

i mean by the crafting table in general.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Statement · Nov 11, 2015 at 10:16 PM

I guess you mean a crafting table, similar to the crafting table in Minecraft?

You'd create patterns for items. Then you test if the pattern exist in the table. If multiple patterns exist in the table, choose the biggest pattern (for example a door may be 2x3 and a box may be 2x2 - the door trumps the box).

You can see the solution to another answer I provided, which contain a basic pattern matching algorithm.

Then you could define patterns for your recepies:

  int[,] boxPattern = {
      { 1, 1 },
      { 1, 1 },
  };
  int[,] doorPattern = {
      { 1, 1 },
      { 1, 1 },
      { 1, 1 },
  };
  int[,] chestPattern = {
      { 1, 1, 1 },
      { 1, 1, 1 },
  };

...For example (1 could mean "wood" or whatever material you want, it's up to you do decide).

Then you could bind patterns to items.

 // To give patterns a name, basically...
 class Recepie
 {
     public string name;
     public int[,] pattern;
 }

And add other information you want to include in your crafting process, it's up to you.

Finally, you can test it as HasPattern(table, recepie.pattern) to see if you got a match.

If you do, save the result and try the next recepie. The "biggest" recepie will then be selected as the item the player wanted to craft, and so you can craft that item Craft(recepieWithLargestPattern.name)

Comment
Add comment · Show 4 · Share
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 Statement · Nov 11, 2015 at 10:21 PM 0
Share

Note that the example would match both box, door and chest if the player put all ones in the table:

 1, 1, 1
 1, 1, 1
 1, 1, 1

The above would match box, door and chest. Door and chest are equally large so the algorithm would have picked either door or chest, but we can clearly see it's undesirable to do either (I guess). So you may want to either add rules that everything else must be blank, or specify blanks in the pattern.

 int[,] boxPattern = {
     { 0, 0, 0 },
     { 0, 1, 1 },
     { 0, 1, 1 },
 };
 int[,] doorPattern = {
     { 0, 1, 1 },
     { 0, 1, 1 },
     { 0, 1, 1 },
 };
 int[,] chestPattern = {
     { 0, 0, 0 },
     { 1, 1, 1 },
     { 1, 1, 1 },
 };

However this solution would work, it would mean you'd have to explicitly define every possible permutation of the table, which feel tedious. You could ins$$anonymous$$d modify the example algorithm I linked to optionally require "all other slots must be 0".

avatar image Statement · Nov 11, 2015 at 10:25 PM 0
Share

Perhaps an improvement for readability when designing the patterns would be to use characters ins$$anonymous$$d of numbers to represent type.

 'w', 'w'
 'w', 'w'

This would perhaps make it easier to understand that it should match wood.

 '*', 'w', '*'
 ' ', 'w', ' '

This would perhaps make it easier to understand you want to match a 2 slot tall wooden shaft, with two arbitrary recepie types.

avatar image Statement Statement · Nov 11, 2015 at 10:28 PM 0
Share

Obviously, if you want to get serious about it, you could create your own kind of DSL or pattern style with parsers to help you solve the task

 pattern.Add("*W*");
 pattern.Add(" W ");

Or even more complex

 pattern.Add($$anonymous$$atch.Any,   $$anonymous$$atch.Type("Wood"), $$anonymous$$atch.Any);
 pattern.Add($$anonymous$$atch.Blank, $$anonymous$$atch.Type("Wood"), $$anonymous$$atch.Blank);

And use types with rich logic, basically programming the pattern recognition task.

avatar image J.E.N.S. · Nov 11, 2015 at 10:29 PM 0
Share

Thank you i'm trying to make a good survival game and that really helped me thank you.

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

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How can i loop through stack and take a set number from each? 0 Answers

Help with crafting system similar to terraria 0 Answers

How to check which button was clicked from script. 1 Answer

2d mobile Multi Scene inventory 0 Answers

Inventory and crafting 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges