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
-1
Question by mivi06 · Jan 15, 2012 at 05:30 PM · androidtouchfinger

finger tap instead of mouse click?

i have unity 3.4 with license full! i build it .apk it opend on my phone but doesnt function, becz i neead a script for touch. my script is whenever i click with the mouse the box disappears. how can i change the mouse click to finger touch? this is my script

function OnMouseDown(){

//if cube's texture isn't locked texture then it loads level number which we gave it in editor

if(renderer.material.mainTexture != lock){

Application.LoadLevel(loadlevel);

}

}

Please Help!

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

5 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Noah-1 · Jan 15, 2012 at 10:33 PM

Here you go!

function Update(){

//if cube's texture isn't locked texture then it loads level number which we gave it in editor

if(Input.touchCount > 0 && renderer.material.mainTexture != lock){

Application.LoadLevel(loadlevel);

}

}

Comment
Add comment · Show 3 · 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 mivi06 · Jan 16, 2012 at 05:16 AM 0
Share

im getting this error: Assets/codes/click.js(11,12): BCE0005: $$anonymous$$ identifier: 'input'. Assets/codes/click.js(11,12): BCE0005: $$anonymous$$ identifier: 'lock'. Assets/codes/click.js(11,12): BCE0005: $$anonymous$$ identifier: 'loadlevel '.

avatar image Meltdown · Jan 16, 2012 at 08:47 AM 0
Share

$$anonymous$$ivi I suggest you learn how to script correctly before trying to write scripts. Do some tutorials and read the docs. Then you'll know what you're doing.

avatar image mivi06 · Jan 16, 2012 at 08:50 AM 0
Share

Thank YOU!!!! IT WOR$$anonymous$$ED THAN$$anonymous$$ YOU! AND YES U ARE WRITE I HAVE TO LEARN $$anonymous$$ORE ABOUT SCRIPTING THAN$$anonymous$$ YOU!

avatar image
1

Answer by DaveA · Jan 16, 2012 at 06:02 AM

// Something like this #if UNITY_IPHONE || UNITY_ANDROID if (Input.touchCount == 1) { if (Input.GetTouch(0).phase == TouchPhase.Began) { var ray = Camera.main.ScreenPointToRay (Input.GetTouch(0).position); var hit; if (collider && collider.Raycast (ray, hit, 100.0)) { OnMouseDown(); } } } #endif where OnMouseDown is your normal OnMouseDown handler

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 mivi06 · Jan 16, 2012 at 08:48 AM 1
Share

DAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVE! IT WOOOOOOOOOOOOOOOOOOOOOOOOOOOOOR$$anonymous$$ED! URE A GENIUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUS!!!!!!!!! THAAAAN$$anonymous$$ YOUUU!

AND THAN$$anonymous$$S TO EVERYONE WHO HELPED $$anonymous$$EEEEEEE! EVERY ONE THAN$$anonymous$$ YOU!

avatar image Meltdown · Jan 16, 2012 at 08:49 AM 0
Share

lol glad you got it working. Also you can search Unity Answers in the top right search box, there are lots of people who have had your problems before and its been resolved.

avatar image mivi06 · Jan 16, 2012 at 10:30 AM 0
Share

Thank You $$anonymous$$eltdown, i got a little problem now, now that this script is working fine with the boxes(3d) but for my text is not working why? i double checked everything!

avatar image mivi06 · Jan 16, 2012 at 12:19 PM 0
Share

Guys i fixed the problem, heheeee thannk u again if u need anythng i do my best to help u! thank u again! without u i wouldnt acheive it

avatar image
1

Answer by reptilebeats · Jan 16, 2012 at 10:55 AM

Go look up tornado twins on youtube for good scripting lessons some are free and giva a basic understanding as long as you write the scripts not just look at them..

I only learned how to script a few months ago and i got to say its a lot easier than i thought it would be you just need to know how a computer speaks. Like learning chinese or summin.

Also look for a youtube page by willgoldstone. He gives in depth tutorials and most use scripts. Follow each one carfully then try to write the script out yourself thats how i learned

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 Meltdown · Jan 15, 2012 at 05:44 PM

Use

 if(Input.GetMouseButtonDown(0))
 {
   // To determine which object was clicked use a raycast
 }
Comment
Add comment · Show 10 · 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 mivi06 · Jan 15, 2012 at 06:03 PM 0
Share

hey thanks, but i dont want to make it for pc i want to make the game for android touch pads, so ins$$anonymous$$d of clicking it with a mouse i want to tap it with my finger so what script should i add or edit please i need this thank you!!

avatar image Meltdown · Jan 15, 2012 at 06:05 PM 0
Share

Don't post comments as answers. Post a comment under the answer you want. Like I have done on this.

I read your question correctly and yes Input.Get$$anonymous$$ouseButtonDown(0) works on IPhone and Android. Try it.

avatar image mivi06 · Jan 15, 2012 at 06:25 PM 0
Share

ahaa,thank you for your advicE!!!!!!!! i willl try it now! but i didnt understand this part: "To deter$$anonymous$$e which object was clicked use a raycast"

avatar image mivi06 · Jan 15, 2012 at 06:58 PM 0
Share

man i tried i changed and i couldnt play it on android, whenever i touch the box ntn happend this is the changd scripts:

static var turnOn:boolean=true; //when this is false we can't click on objects. it is falsing from $$anonymous$$ILLER script when we won or faild.

function Start(){ turnOn=true; }

function On$$anonymous$$ouseDown () { if(Input.Get$$anonymous$$ouseButtonDown(0)) { //if turnon is true plays attached sound then waits 0.1 second and destroys cube if(turnOn){ audio.Play(); yield WaitForSeconds (0.1); Destroy(gameObject); } } }

please can u help me please, btw what's ur e-mail this way we can chat live and understand more to each other thank youu!

avatar image Meltdown · Jan 15, 2012 at 07:07 PM 0
Share

Sorry I forgot to mention you need to put Input.Get$$anonymous$$ouseButtonDown(0) in your Update() function. You need to remove function On$$anonymous$$ouseDown()

Show more comments
avatar image
0

Answer by reptilebeats · Jan 15, 2012 at 09:01 PM

im pretty sure you have to use input.getTouch instead, or else multiple touch is disabled. cheack out the scripting reference and scroll down there should be a page on android scripts there

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 mivi06 · Jan 15, 2012 at 09:07 PM 0
Share

so can u fix my script and write it for me so i can see it, cz im new to progra$$anonymous$$g and i rlly need this thank you

avatar image mivi06 · Jan 16, 2012 at 02:28 AM 0
Share

update cannot be coroutine? why am i getting this error? and guys now i lost: shoul i put input.getTouch

             or

Input.Get$$anonymous$$ouseButtonDown

?? please help and thank you for all u did!!!!

avatar image Meltdown · Jan 16, 2012 at 08:48 AM 0
Share

Both ways work you need to learn how to script properly and read the docs. And nobody here is going to write scripts for you.

avatar image mivi06 · Jan 16, 2012 at 08:51 AM 0
Share

Thank You For All Ur Help!!!!!!1 $$anonymous$$ay You Achieve $$anonymous$$ore Success!!

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

9 People are following this question.

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

Related Questions

Do On swipe finger? 1 Answer

Finger gesture works/fails on different devices? 0 Answers

appear android touch key board 0 Answers

Android Drag By Steps 0 Answers

Detecting onDrag over UI images 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