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 /
avatar image
0
Question by dogiordano · Aug 29, 2016 at 01:41 PM · mouse follow

Mouse Follow Problem

Hello, I'm using Unity Personal to develop a simple 2D game.

I made a Scene with just an Othographic Camera and one object with a single script to illustrate the problem:

 void Update () {
     Vector3 target = Camera.main.ScreenToWorldPoint(Input.mousePosition);
     target.z = 0;
     transform.position = target;
 }

This script will make the object follow the mouse.

The "target.z = 0" part is because the camera is looking up the z axis and I want the object to stay on the z=0 plane.

Problem: moving the mouse fast enough results in an offset between it and the object.

alt text

My game is touch and I don't like the collider area getting away from the finger.

What is the cause? If the Update frequency is too low, is there a way I can increase it? If not, what can I do about it?

Thanks.

offset.png (30.4 kB)
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 Cynikal · Aug 29, 2016 at 04:09 PM

Unfortunately, there will always be a slight delay.

You're moving the mouse. Unity then has to know where the mouse has moved to, then translate that info to the game object, then the renderer has to render the changes, etc. Point being, if you consider the mouse as Process 1, the actual display of moving the box would be like, Process 10. Now, considering that you're continually moving the mouse, it gets ramped up.

You said your game was a touch game. Cool. I understand you're using a mouse during testing. Computer mice use acceleration. Your finger on a phone...would not. Export it to a phone, then see if the issue is as bad as it is with the mouse.

There isn't a way to increase the update, as it's the "fastest" firing method. (Multiple times per frame)

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 dogiordano · Aug 30, 2016 at 01:05 PM 0
Share

@Cynikal I did the tests on a phone and the problem is even more noticeable. Probably because rendering is even slower there and it's quite confusing for the player.

I just made a test removing VSync and I hit 2200 FPS. Useless to say this is fast enough for the offset to disappear.

So I might post another questions on the disadvantages of disabling VSync or study a bit more first. But even now I guess that would put the phone under a lot of stress so it might not be a solution.

Thank you very much for your help.

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

Detect Collisions with Object following Mouse Movement 2 Answers

[2D] Problem With Mouse Follow Object 1 Answer

Mouse Follow (Not Working) - ): 1 Answer

Mouse Look/Follow is not following first person 0 Answers

Mouse follow collider in a 2D game 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