Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 UDN_b4e36b73-b927-4c8f-942d-e2fe41c8a184 · Jan 17, 2017 at 07:59 AM · c#androidunity 5buttonscube

How can I stick buttons on my cube and the same time using script?

Please help me I've been trying to figure out this for a month now...Yeah embarrassing... Well I have a cube with a script for rotating it and my problem is that I wan't to put buttons or idk something similar like "Piano Tiles" on the cube and still use my script for rotating it and also the buttons to be pressed. Please help me solve this issue I am new to game developing and C#.

Also if the code is bad I tried to make a code for touch dragging and rotating my cube feel free to make a brand new code.

Heres my code:

  private float rotationSpeed = 8.0F;
  private float lerpSpeed = 1.0F;
  private Vector3 theSpeed;
  private Vector3 avgSpeed;
  private bool isDragging = false;
  private Vector3 targetSpeedX;
  void OnMouseDown() {
      isDragging = true;
  }
  void Update() {
      if (Input.GetMouseButton(0) && isDragging) {
          theSpeed = new Vector3(-Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"), 0.0F);
          avgSpeed = Vector3.Lerp(avgSpeed, theSpeed, Time.deltaTime * 0);
      } else {
          if (isDragging) {
              theSpeed = avgSpeed;
              isDragging = false;
          }
          float i = Time.deltaTime * lerpSpeed;
          theSpeed = Vector3.Lerp(theSpeed, Vector3.zero, i);
      }
      transform.Rotate(Camera.main.transform.up * theSpeed.x * rotationSpeed, Space.World);
      transform.Rotate(Camera.main.transform.right * theSpeed.y * rotationSpeed, Space.World);
Comment
Add comment · Show 7
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 doublemax · Jan 17, 2017 at 08:00 AM 1
Share

my problem is that I wan't to put buttons or idk something similar like "Piano Tiles" on the cube and still use my script for rotating it and also the buttons to be pressed.

What exactly is the problem, what stops you from doing that?

avatar image UDN_b4e36b73-b927-4c8f-942d-e2fe41c8a184 doublemax · Jan 18, 2017 at 10:28 PM 0
Share

@doublemax Thank you for replying. Well I did add 2D Box Collider to all piano tiles but the main cube has regular Box Collider. And also can you tell me how to code the piano press... Oh and I want it to press when the rotation dragging is stopped and only short touches will press the tiles.If I touch and hold I want it to rotate if i just press once it will click and turn red on a tile etc...If you don't want to give me code please post some tutorials or something similar so I can make this. Thanks again for helping me xD

avatar image UDN_b4e36b73-b927-4c8f-942d-e2fe41c8a184 · Jan 18, 2017 at 02:49 PM 0
Share

@doublemax I don't know how to put like piano tiles on a cube and use the script above for rotation at the same time. Can you explain the easiest way to do it ?

avatar image doublemax UDN_b4e36b73-b927-4c8f-942d-e2fe41c8a184 · Jan 18, 2017 at 03:38 PM 0
Share

For the "piano tiles" you could just create new cubes as children of the big one, scale them accordingly and place them onto the cube.

The question is: If the user touches these tiles, what is supposed to happen? Shall it rotate the cube or should something else happen?

avatar image UDN_b4e36b73-b927-4c8f-942d-e2fe41c8a184 doublemax · Jan 18, 2017 at 04:49 PM 0
Share

@doublemax Well I did that but I can't rotate the cube because I can't touch the big one because of the smaller cubes... I wan't to be able to still rotate the Cube and when I am not dragging with touch I want Piano tiles on the cube and just press them like buttons etc... This is my first game so thank you for helping me build it...

Show more comments
avatar image UDN_b4e36b73-b927-4c8f-942d-e2fe41c8a184 · Jan 18, 2017 at 03:17 PM 0
Share

I don't know how to put like piano tiles on a cube.Can you explain the easiest way to do it ? @doublemax

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

8 People are following this question.

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

Related Questions

Unity project on android - OnPointerDown/Up movement 1 Answer

Unity Android fetching wrong screen resolution 1 Answer

how to describe a android path in c# script 1 Answer

Dialouge isnt working 1 Answer

Google Daydream Thread with Unity 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