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 MinecraftUnity · Jun 02, 2012 at 12:01 AM · javascripttexturecubeminecraft

How to make a Cube with a texture in a JavaScript?

I am completely new to Unity 3D. I own the free version. For my first project, I am trying to make a MineCraft like clone. I followed tutorials, but now i'm trying to change something so it works how I want it. First off, how can I place a cube with a texture on it? Here's a chunk of code where I need to be able to do this:

    function Build() { 
     if (HitBlock()) { 
     var cube = GameObject.CreatePrimitive(PrimitiveType.Cube); 
     cube.transform.position = hit.transform.position + hit.normal; 
     } 
     }

This spawns a default cube with no texture whatsoever. How do I get a texture?

Next, how to I add an arm that follows me around with animation. I know I have to parent it to First Person Controller > Main Camera... But, what do I do for animations? And I have a gun, but I want it only to appear when I press a key, or press a key to get rid of this.

Third, for deleting a brick, how can I force the user to click, but hold down for X amount of time before the Cube breaks? I have an instant delete chunk of code here:

  function Erase() { 
 if (HitBlock()) 
 Destroy(hit.transform.gameObject); 
 }

I know absolutely NO javascript, or java, so I came here.

Comment
Add comment · Show 2
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 whydoidoit · Jun 02, 2012 at 12:23 AM 0
Share

Hi there - welcome on board :)

Just a note - it is a really good idea to ask more than one question when your questions are so different to each other. This is a knowledge base rather than a forum and so it matters that answers clearly follow the heading of the topic.

Also, you will find different people will be able to help of different questions but will be put off by not being sure about all of the answers.

So - please read the FAQ and please feel free to ask each question individually, with as much clarity and detail as possible :)

avatar image whydoidoit · Jun 02, 2012 at 12:26 AM 0
Share

Next point actually is that if you aren't a programmer at all then you will probably be frustrated with the answers or lack of them that you get here. If you are just new to UnityScript (which is somewhat different to Javascript and a whole lot different to Java! - Sorry to tell you) then you might be better off doing some of the tutorials that are available or muddling through.

Tutorials:

  • http://unity3d.com/support/resources/tutorials/

  • http://www.burgzergarcade.com/tutorials

  • http://tornadotwins.com/?page_id=34

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.

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 do I put a texture on my Cube using code (JavaScript) 1 Answer

Primitive Cube Texturing Help 3 Answers

how to change the maintexture from another scene? 1 Answer

Assigning UV Map to model at runtime 0 Answers

Screenshot to variable 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