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 /
This question was closed Feb 04, 2016 at 10:57 AM by Ali-hatem for the following reason:

The question is answered

avatar image
0
Question by Ali-hatem · Feb 03, 2016 at 09:21 AM · touchfinger

object falow finger problem ?

Hi : i want the object only falow the x axis and it's work but the problem with y axis it moves the object to the bottom of the screen and her is my code

  if(Input.touchCount > 0)
     {
             //what ever i giv to the y axis it's the same result !
         Vector3 pl = new Vector3(Input.GetTouch(0).position.x,0,1);
             
         transform.position = Camera.main.ScreenToWorldPoint (pl);
                     
     }

Comment
Add comment · Show 2
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 antx · Feb 03, 2016 at 03:43 PM 0
Share

So what is the actual problem? You set a 0 for y axis. If you want a specific y position you need to set it. Try:

 Vector3 pl = new Vector3(Input.GetTouch(0).position.x, Screen.height / 2.0f, 1);
 transform.position = Camera.main.ScreenToWorldPoint (pl);

(I did not test this. $$anonymous$$ight be that the values are normalized in which case you should use 0.5f ins$$anonymous$$d of "Screen.height / 2.0f").

avatar image Ali-hatem antx · Feb 04, 2016 at 09:11 AM 0
Share

@antx : i already mentioned //what ever i giv to the y axis it's the same result !

4 Replies

  • Sort: 
avatar image
0

Answer by droni · Feb 04, 2016 at 11:12 PM

Its really simple you wrote in the code y = 0 try to use pl.transform.position.y or similar i am not really sure cant check that smartphone user :3

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 droni · Feb 05, 2016 at 02:41 AM

try to use other command or method change the position

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 Nanofication · Feb 05, 2016 at 04:32 PM

I'm assuming this is a 2d game.

So some questions are, is your character zeroed out? aka. the position is (0,0,0)? If the y axis is greater than 0, then your character will move all the way to the bottom of the screen.

If not, I recommend storing your character's position in a Vector3 variable ("startPosition" for example)

and just do Vector3 pl = new Vector3(Input.GetTouch(0).position.x, startPosition.y, startPosition.z)

This is to keep your character's y and z position relative to its starting position.

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 Ali-hatem · Feb 04, 2016 at 10:56 AM

ok i found out the problem when i give zero to the ( y axis ) i send the object to the zero axis of the camera because that what //Camera.main.ScreenToWorldPoint do.

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

Follow this Question

Answers Answers and Comments

44 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

Related Questions

touch input error - finger position offset 2 Answers

two finger touch always detects one finger touch first 1 Answer

How I make finger touch move texture offset 0 Answers

finger tap instead of mouse click? 5 Answers

Finger gesture works/fails on different devices? 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