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 Vliegtuigfan · Aug 06, 2013 at 09:19 AM · javascriptplayertouchitem

Player touch item?

I need a Javascript... When a player touch the cube, then scene 1 will load...

I have this found on Internet:

 Application.LoadLevel ("HighScore");

But what's next? I'm pretty bad in Javascript.

Thanks

Comment
Add comment · Show 3
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 DaveA · Aug 06, 2013 at 09:24 AM 0
Share

How are your googling skills?

avatar image Vliegtuigfan · Aug 06, 2013 at 09:29 AM 0
Share

I can't anything! But, you can try it :)

avatar image DaveA · Aug 06, 2013 at 09:53 AM 1
Share

http://lmgtfy.com/?q=unity+touch+object

3 Replies

· Add your reply
  • Sort: 
avatar image
-1

Answer by liszto · Aug 06, 2013 at 09:40 AM

You can do this :

 Application.LoadLevel ("TheNameOfYourScene");

but I think you will need more than that to do what you want after this small step.

Comment
Add comment · Show 1 · 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 Vliegtuigfan · Aug 06, 2013 at 09:49 AM 0
Share

Yes, i know that line... But not what needs to happen: (

avatar image
0

Answer by christinam · Aug 06, 2013 at 09:31 AM

Have a look at the Input class in the script reference : http://docs.unity3d.com/Documentation/ScriptReference/Input.html

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 Joyrider · Aug 06, 2013 at 09:54 AM

I'm more of a c# guy, so I'm not going to try to write the script but the logic would be somehting like this:

1/ Add a boxcollider to your cube

2/ Write a script with this logic in it and add it to your camera for example.

 var cubeCollider : Collider;

 if(Input.GetButtonDown(0)) // you should change this if you're using multi-touch
 {
     Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); // also to be changed if on multitouch
     RaycastHit hit;
     if (Physics.Raycast(ray, out hit, 100)) // cast a ray and check if something was hit
     {
        if(hit.collider == cubeCollider) // if something was hit, check if collider is that of the cube
        {
            Application.LoadLevel(1); // Loading scene 1
        }
     }
 }

3/ drag your cube in the cubeCollider variable exposed in the inspector

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

18 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

Related Questions

I need help translating Javascript to C# 0 Answers

Singletons in music script? 2 Answers

Touch Control Android Java 0 Answers

Enemy detection in the light(Javascript) 1 Answer

Simple EXP Script In Javascript 0 Answers


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