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 vijaypandu6 · Jun 12, 2015 at 01:08 PM · not workingtouchestwo

two OnMouseDowns are not working at a time.

two "OnMouseDowns" are not working at a time.hi to all, i'm working as unity trainee in Hyderabad. right now i'm doing horse game,in this game i have joystick to move horse and a jump button to jump horse. please give me an idea to work both at a time.

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 tanoshimi · Jun 12, 2015 at 01:11 PM

How good are your reactions? Unless you're pressing both buttons in exactly the same frame (i.e. within 1/60th of a second of each other if your game runs at 60FPS), then you're not going to get OnMouseDown events for both of them firing. I suspect you meant to use GetMouseButton, not GetMouseButtonDown.

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 vijaypandu6 · Jun 13, 2015 at 05:03 AM 0
Share

yeah i use Get$$anonymous$$ouseButton(0), but no use both are not working at a time. in joystick script i am using bellow script

private var object : Transform; // The object we will move. private var offSet : Vector3; // The object's position relative to the mouse position. private var dist : float;

function Update () {

 var ray=Camera.main.ScreenPointToRay(Input.mousePosition);  // Gets the mouse position in the form of a ray.
  
  if (Input.GetButton("Fire1")) {     // If we click the mouse...
  
      if (!object) {      // And we are not currently moving an object...
  
          var hit : RaycastHit;

if (Physics.Raycast(ray, hit,5)) { // Then see if an object is beneath us using raycasting.

  if (hit.transform.name == "Tunnel-Trouble-btn_2") {
      object = hit.transform;     // If we hit an object then hold on to the object.
      
      offSet = object.position-ray.origin;        // This is so when you click on an object its center does not align with mouse position.
  }

} /* if (Physics.Raycast(ray, hit, $$anonymous$$athf.Infinity) && (hit.collider.tag == "Draggable")) { // Then see if an object is beneath us using raycasting.

              object = hit.transform;     // If we hit an object then hold on to the object.
  
              offSet = object.position-hit.point;        // This is so when you click on an object its center does not align with mouse position.
              
              dist = (ray.origin - hit.point).magnitude;  // Distance to the object from ray origin.
  
          }*/
  
      }
  
  }
  
  else if (Input.GetButtonUp("Fire1")) {
  
      object = null; 
         transform.localPosition.x=-0.25;
 transform.localPosition.y=0.1;
     transform.localPosition.z=-0.46;    // Let go of the object.
  
  }
  
  if (object) {
  
      object.position = ray.GetPoint(dist) + offSet;    // Only move the object on a 2D plane.
  
  }
  

}

avatar image vijaypandu6 · Jun 13, 2015 at 07:01 PM 0
Share

yeah i used Get$$anonymous$$ouseButton. but there is no use. booth are not working at a time.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Click Two objects At Once Windows 7 Touch 1 Answer

Remove space between two objects at runtime 0 Answers

ray=Camera.main.ScreenPointToRay(Input.touches[0].position); 1 Answer

Do we need to write different code to different platforms?? 0 Answers

Detecting RayCast on moving object? 4 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