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 Adnre · Nov 03, 2010 at 01:04 PM · iphoneipadipod

In priview good work, but on Iphone - incorect

Please help me. This code:

function Update () {    
    var fingerCount = 0;
    for (var touch : iPhoneTouch in iPhoneInput.touches) {
        if(touch.phase==iPhoneTouchPhase.Ended)
        {
        var ray : Ray = Camera.main.ScreenPointToRay (touch.position);
        hits = Physics.RaycastAll (ray.origin,ray.direction,300);
        control_j(hits); <- this incorect work
        }
        if (touch.phase != iPhoneTouchPhase.Ended && touch.phase != iPhoneTouchPhase.Canceled)
        {
        fingerCount++;
        }
    }
    if(Input.GetMouseButtonDown(0))
    {
    ray = Camera.main.ScreenPointToRay (Input.mousePosition);
    hits = Physics.RaycastAll (ray.origin,ray.direction,300);
    control_j(hits); <- this good work      
    }
}

Maybe i bad use iPhoneTouch. Why if i use mouse - good work, but if install on IPad or IPhone or IPod - bad work. 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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Proclyon · Nov 03, 2010 at 01:21 PM

if(Input.GetMouseButtonDown(0))
{
    ray = Camera.main.ScreenPointToRay (Input.mousePosition);
    hits = Physics.RaycastAll (ray.origin,ray.direction,300);
    control_j(hits); <- this good work      
}

This piece of your code responds to a mouseclick. This will not register on the Iphone since it does not handle input for a mouse. All code in it will never be used.

Comparing it with the other code sample doesn't make much sense to me since assuming that Iphone controls that are differently coded will work just because the mouse controls worked. This a dangerous assumption and can lead to design problems aswell because of corrupts the train of mind if done regularly.

Given the information you have supplied me with I can't help you with any more then that yet. Are you programming in script for Unity Engine only, or are you bringing along .NET? Why make a ray variable over and over in the for loop? What are you trying to achieve with the code , e.a. , what is it's preferred behaviour?

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 Adnre · Nov 04, 2010 at 02:49 AM

for Iphone I use (test on IPhone 3G, IPad, IPod):

for (var touch : iPhoneTouch in iPhoneInput.touches) {
    if(touch.phase==iPhoneTouchPhase.Ended)
    {
    var ray : Ray = Camera.main.ScreenPointToRay (touch.position);
    hits = Physics.RaycastAll (ray.origin,ray.direction,300);
    control_j(hits); <- this incorect work
    }
    if (touch.phase != iPhoneTouchPhase.Ended && touch.phase != iPhoneTouchPhase.Canceled)
    {
    fingerCount++;
    }
}

This function "control_j(hits);" use only hits variable.

for mouse I use (test on PC (Mac)):

if(Input.GetMouseButtonDown(0))
    {
    ray = Camera.main.ScreenPointToRay (Input.mousePosition);
    hits = Physics.RaycastAll (ray.origin,ray.direction,300);
    control_j(hits); <- this good work      
    }

I need analog (Objective C XCode):

- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {

}

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

No one has followed this question yet.

Related Questions

How do you make an iPhone Game with Unity? 4 Answers

iPad touch scripting... 0 Answers

iOS Universal Binary Support? 1 Answer

Are apps that use AssetBundles always out-of-luck when a client's offline? 1 Answer

Replace Graphics with inserted picture 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