Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
3
Question by benedikte · Sep 11, 2010 at 08:44 AM · iphonetouchipadcoordinates

How do I get ipad coordinate to match the ones in the editor?

I place an object in the unity iphone editor at (0,0,0). And I have a script that gives me the coordinates of a touch. When a run the app on the ipad a touch the place of my (0,0,0)-object then a get a debug message with a different coordinates then the (0,0,0).

How do I get the touch-coordinates to match the ones I set in the editor.

Hopes my questions makes sense and thank you for helping :)

(i'm working with an orthographic camera) I guess I'm asking for a way to control the relatioin between the cameras position a the screen space.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by jtbentley · Sep 13, 2010 at 11:28 PM

I think the problem is you're getting the position of the collision itself (where the ray hits the collider). It sounds like what you want is the transform co-ords of the object you have hit.

So rather than hit.point, you'll want to find out what you hit, then get its transform. hit.collider.transform.position :)

var ray = Camera.main.ScreenPointToRay (Input.mousePosition); var hit : RaycastHit;

if (Physics.Raycast (ray, hit, 200)) 
{
    var objecthit:Transform = hit.transform as Transform;
        print ("Object is positioned at :"+hit.collider.transform.position);
}
Comment
Add comment · Show 2 · 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 benedikte · Sep 17, 2010 at 10:26 AM 0
Share

Thank you for the reply. It was a step in the right direction for me. I have to realise the difference between the "pixel-space" and the 3d space within unity.

I still don't get the link between the camera output I see in unity and the section of my scene I see on the ipad. How I can place or adjust the camera so I e.g. get my object centred on the ipad. I'm still so new at this that I don't even now what exactly I'm looking for.

avatar image Thom Denick · Jan 05, 2011 at 04:35 PM 0
Share

Yeah, you should not be using precise coordinates - you should be testing for collision with your object. Using absolute numbers like that will end up screwing you if you have to change the slightest thing in the editor. You will have to go back and adjust all those coordinates manually. (I know this from mistakes I've made myself learning in the past 6 months.)

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

rotate object to touch position 1 Answer

How do you map touch points to world space? 1 Answer

Instantiating by touch on iPhone/iPad 1 Answer

Working with Touch screens... 1 Answer

translating a touchDeltaPosition from the y axis to z axis 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