Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
0
Question by LFZ2 · Jan 23, 2011 at 01:45 PM · objectaddminecraftfacestyle

Add object to another object's selected face

Hello, I've been strugling for the past few days to create a simple system to add a object, (cube for example) next to another object's face the same way minecraft does it. Anyone have any ideas? Probably share a bit of code?

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Jesse Anders · Jan 23, 2011 at 03:51 PM

I answered a similar question recently (maybe it was yours)?

Anyway, to do something like Minecraft, you probably want to use a grid system in order to ensure that the results are deterministic (rather than, for example, computing the coordinates for the new cube relative to the coordinates of another cube).

With this method, each cube would have its own integer 'grid coordinates'; the actual world position would then just be a scalar multiple of the grid coordinates (possibly with other transformations applied if desired).

When raycasting against a cube, you'll get a normal back if there's a hit. From this normal, you can determine what side of the cube was hit, and also in which direction in 'grid space' the corresponding neighboring grid cell is. You can then create a new cube in that grid space.

Comment
Add comment · Show 2 · 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 LFZ2 · Jan 23, 2011 at 08:22 PM 0
Share

Hmm it is the first question related to "$$anonymous$$ecraft style" content I'm asking, but I have a little doubt that this isn't going to work right. Im thinking this because if you go "below or beyond" the grid, there might be complications and the results are wrong.

avatar image Jesse Anders · Jan 23, 2011 at 08:27 PM 1
Share

The grid can be implicit or non-bounded, so there shouldn't necessarily need to be any 'below or beyond'. The point is simply to give each cube a set of integer coordinates, both for deter$$anonymous$$istic placement and to be able to reason about the cubes in 'grid space', which will likely be useful. (Although I haven't implemented anything like this, I imagine the cubes are typically stored in a hash table or something, in which case the integer coordinates can serve as the source of the hash code for each cube.)

avatar image
0

Answer by DavidDebnar · Jul 09, 2011 at 07:10 AM

Posting this like for the 5th time... First get mouse raycast, than when player presses for example LMB it instantiates a block and stores it into a var and than rounds that number to the grid size.

block.position.x = Mathf.Round(actualBlock.position.x);
block.position.y = Mathf.Round(actualBlock.position.y);
block.position.z = Mathf.Round(actualBlock.position.z);
Comment
Add comment · 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

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.

Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

How to make a block have highlighted lines like it does in minecraft 2 Answers

Creating multiple faces (cubes) 1 Answer

How to get Var from a obj 1 Answer

Place block script 1 Answer

How to move object base on where it is facing? 0 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