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 kickasskane · Jun 04, 2012 at 06:56 PM · worldminecraftblocks

Minecraft Bedrock help

Hello, I have been working on a minecraft game for quite a while now and I am having some problems with creating Bedrock (Undestroyable block) for the bottom and edges of my world. This is my script:

 using UnityEngine;

using System.Collections;

public class BuildScript : MonoBehaviour {

 RaycastHit hit;
 
 public Transform prefab;

 // Use this for initialization
 void Start () {
 
 }
 
 // Update is called once per frame
 void Update () {
     
     Ray ray = camera.ViewportPointToRay(new Vector3(0.5F, 0.5F, 0));
     
     Vector3 G = new Vector3(Mathf.Round(hit.point.x), Mathf.Ceil(hit.point.y), Mathf.Round(hit.point.z));
     
     if(Physics.Raycast(ray, out hit)){
         
         if(Input.GetMouseButtonDown(1)){
             Destroy(hit.collider.gameObject);
             
         }
         
         
         if(Input.GetKeyDown("q")){
             Instantiate(prefab, G, Quaternion.identity);
         }
         
     }
 
 }

}

It works perfectly exept it is Destroy(hit.collider.gameObject); and it destroys any object, I would like the bedrock to be undestroyable. But everything else is, Please help me.

P.S. I also need help with the terrain, I need a random terrain of different heights made of cubes. This would be a massive help, Thankyou.

-Kickasskane Productions

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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by ExTheSea · Jun 04, 2012 at 07:08 PM

I can't really help you with the terrain but for the bedrock:

You could either differ this block from another by the name like this:

 ...
 if(Input.GetMouseButtonDown(1)){
     if(hit.collider.gameObject.name!="Bedrock")
          Destroy(hit.collider.gameObject);
 
        }
 ...

or you can add a tag to the Bedrock-gameobject then it would be hit.collider.gameObject.tag !="Bedrock" and so on and so forth

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
avatar image
0

Answer by kolban · Jun 04, 2012 at 07:08 PM

You didn't describe the logic you employed in your script but if I understand it correctly, you are casting a ray and, if the ray hits something AND the mouse button is down then delete the game object that was hit by the ray. If you want to "not" delete some game object in this story then you will need to provide some "marker" on that game object to flag it as undeletable. For example, perhaps define a new game tag type called "undeletable" and flag these game objects as having this tag. Then in your code you could have the following:

 if (Input.GetMouseButtonDown(1) && hit.collider.gameObject.tag != "undeleteable")

Using an attached tag value is one way of detecting marked game objects. Another would be attached scripts with properties.

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
avatar image
0

Answer by Loius · Jun 04, 2012 at 07:16 PM

Well... if you hit bedrock, do nothing. Otherwise, destroy the hit object.

 if ( hit.collider.gameObject.tag = "bedrock" ) {
 } else {
   Destroy( hit.collider.gameObject );
 }

Obviously you'd want to set the bedrock object(s) to have the bedrock tag.

For the random terrain...

Start at a random height, build cubes from bedrock to [height]. For each terrain position, choose a height close to an adjacent height, then build cubes from bedrock to [height].

Note - This is really really inefficient. Storing that many cubes will explode the computer. There are ten billion questions on here about minecraft, though, and some of them even have helpful answers.

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

6 People are following this question.

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

Related Questions

Multiple Cars not working 1 Answer

World Spawn Layer under current Layer 1 Answer

Blocky terrain optimization 1 Answer

I made a better shader how do i fix[add _Shadow Strength]help???>Sorry that im asking for to much 1 Answer

Cannot convert 'UnityEngine.GameObject' to 'UnityEngine.Transform' 1 Answer


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