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 gouchikamori · Oct 10, 2017 at 09:04 AM · script.mobiletap

Script when tapping an object

I am trying to create a mobile app (Android).

①: Tap the object "Cube 1" ②: When you do ①, the object "Cube 2" is displayed. ("Cube 1" will be hidden)

What kind of script should I make when implementing the above behavior?

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
0

Answer by goutham12 · Oct 10, 2017 at 09:18 AM

can you clarify a bit more like

if cube1 clicked ----->cube1 will go to hidden and cube 2 will display up to here fine.

what if he taps on cube2 is there any other functionality.

if yes , then

bool click;

publick GameObject cube1,cube2;

if (Input.GetMouseButtonDown (0)) {

Ray ray = Camera. main. ScreenPointToRay(Input. mousePosition);

RaycastHit hit;

if(Physics. Raycast (ray, out hit))

{

if(hit. transform. gameobject.tag == "your cube's tag")

{

click = !click;

if(click){

cube1.setactive(false);

cube1.setactive(true);

}else{

cube1.setactive(true);

cube2.setactive(false);

}

}

}

if no then

do the above only when click true

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 lernoh · Oct 10, 2017 at 11:32 AM

Oh that is interesting for me too. But I am going to use that in online multiplayer via browser. Can I use this script ? and on which object should I put this script? To create an empty and tag as a player? or game manager ?

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 goutham12 · Oct 10, 2017 at 12:43 PM 0
Share

For multiplayer this code doesn't work. can you explain me a bit brief that what you exactly needed.

avatar image lernoh goutham12 · Oct 10, 2017 at 02:30 PM 0
Share

I need to create a 2d simple game in 3d space. All is needed to do is to choose one of 3 boxes. and if some of boxes choosen it becomes inactive for other online players who are playing via browser. And after they have already made their choise the system randomly chooses one of that 3boxes. So now I have made all the objects but I need some script which will allow the players to choose their boxes. If any ideas concerning to this please please tell me. or give me some hint. any simple word can be useful. Thanks. :) !!!!

avatar image goutham12 · Oct 11, 2017 at 05:37 AM 0
Share

first for multiplayer game the above code works 0%

let me know which network your are using for multiplayer game. i mean photon or unity network.

avatar image lernoh goutham12 · Oct 11, 2017 at 10:31 AM 0
Share

I don't even know what's the differencebetween them , but i use unity network.

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

104 People are following this question.

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

Related Questions

Mobile platformer jump not working 2D 1 Answer

[iOS/Android] U3D repeats tap to new scene 0 Answers

Mobile Tap Issue 1 Answer

please please please very urgent, can someone convert this script for android swipe 0 Answers

How to make mouse click and tap work in same cases on boxCollider2d 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