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 stevenp · Mar 27, 2012 at 03:49 AM · iphonetouchmousefollow

Mouse follow performance in iPhone

Hi guys!

I want to make a game object to follow my mouse pointer and it's working perfectly in desktop however in iPhone the object movement is delayed. I assume it's because of the processing power and probably my method is not suitable for iPhone, I'm not really sure. So far, here is the script for mouse follow.

 private var depth : float;
 private var count : int;
 private var touch : Touch;
 private var wantedPos : Vector3;
 
 function Awake(){
     this.renderer.enabled = false;
     depth = 10;
 }
 
 InvokeRepeating("FollowMouse", 0, 0.1);
 
 function FollowMouse(){
     count = Input.touchCount;
     touch = Input.GetTouch(0);
     if(touch.phase == TouchPhase.Moved){
         wantedPos = Camera.main.ScreenToWorldPoint(touch.position);
         transform.position = wantedPos;
     }
 }

If in iPhone, the game object is a bit late so it's following behind the touch position while in desktop, the game object can perfectly follow the mouse location. Thanks in advance! =)

EDIT: Changed from using mouse input to touch input.

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
0

Answer by Kiloblargh · Mar 27, 2012 at 03:56 AM

Why is "this.renderer.enabled = false" in Update, rather than Awake? Also, never declare variables in Update. Declare them at the start of the script and include types. If it's still too slow, replace Update with an InvokeRepeating that goes 15 times a second or so.

You shouldn't be using anything "mouse" related on the iPhone anyway. It will probably stop working in an upcoming version of iOS or Unity.

http://unity3d.com/support/documentation/ScriptReference/Input.GetTouch.html

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 stevenp · Mar 27, 2012 at 04:43 AM 0
Share

Ok, I've changed from using mouse input to touch input but it's still the same result. I tried using Update() but it's still the same so I changed to InvokeRepeating() but it's the same as well. Does the point conversion Camera.main.ScreenToWorldPoint has anything to do with performance?

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to detect Game Object is touched in Unity iPhone? 1 Answer

translating a touchDeltaPosition from the y axis to z axis 1 Answer

Holding a Touch down on the iphone 2 Answers

Joystick C# change touch zone? 0 Answers

iPhone - Collision sometimes not detected when swiping too fast 2 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