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 ealva479 · Apr 30, 2019 at 02:11 PM · mousemousepositionrts

Mouse input not being recognised

Out of nowhere, my rts camera stopped recognising certain mouse actions. I can't select units anymore, and trying to place building pieces messes up because their transform isn't getting set to the mouse position anymore. When I try to select a unit, it only registers the terrain and nothing else. I am still able to click on trees and rocks and they get recognised, but that's it....

Comment
Add comment · Show 6
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 DCordoba · May 01, 2019 at 04:53 AM 0
Share

well, how you pickup the inputs, the "units" have colliders? de device is a standard mouse? please provide more info...

avatar image ealva479 DCordoba · May 01, 2019 at 04:07 PM 0
Share

Yes, the units have a navmeshagent and a box collider attached. It is just a standard mouse. Here is the code used:

             //Detect if mouse is down
             if (Input.Get$$anonymous$$ouseButtonDown(0))
             {
                 mousePositon = Input.mousePosition;
                 //Create a ray from the camera to our space
                 var camRay = rtsCam.ScreenPointToRay(Input.mousePosition);
                 //Shoot that ray and get the hit data
                 if (Physics.Raycast(camRay, out hit))
                 {
                     Debug.Log(hit.transform);
                     if (hit.transform.CompareTag("PlayerUnit"))
                     {
                         print("player unit found");
                         SelectUnit(hit.transform.GetComponent<UnitController>(), Input.Get$$anonymous$$ey($$anonymous$$eyCode.LeftShift));
                     }
                     else
                     {
                         isDragging = true;
                     }
                 }
 
             }
avatar image KevRev ealva479 · May 01, 2019 at 04:13 PM 0
Share

Do you get any errors?
What is the debug output? And does it ever match what you believe you are clicking on?

Show more comments
avatar image KevRev · May 01, 2019 at 07:31 AM 0
Share

You'll need to share your code and explain how it currently selects, whether you have any errors and what you have tried so far.

avatar image ealva479 KevRev · May 01, 2019 at 04:08 PM 0
Share
             //Detect if mouse is down
             if (Input.Get$$anonymous$$ouseButtonDown(0))
             {
                 mousePositon = Input.mousePosition;
                 //Create a ray from the camera to our space
                 var camRay = rtsCam.ScreenPointToRay(Input.mousePosition);
                 //Shoot that ray and get the hit data
                 if (Physics.Raycast(camRay, out hit))
                 {
                     Debug.Log(hit.transform);
                     if (hit.transform.CompareTag("PlayerUnit"))
                     {
                         print("player unit found");
                         SelectUnit(hit.transform.GetComponent<UnitController>(), Input.Get$$anonymous$$ey($$anonymous$$eyCode.LeftShift));
                     }
                     else
                     {
                         isDragging = true;
                     }
                 }
 
             }


There are no errors, just simply nothing happening. The unit has a box collider and navmeshagent, I don't know if those conflict with eachother but I haven't had problems yet.

0 Replies

· Add your reply
  • Sort: 

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

117 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 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 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

Examples of TBS/Heavily Gui-driven Games in Unity? 2 Answers

3D mouse position 0 Answers

Ray Over Mouse 1 Answer

How I can save mouse position ? 0 Answers

How to prevent GameObject from spawning on top of each other? 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