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 rocketeer13 · Jun 30, 2013 at 11:13 PM · inputmousecontrol

Implementing a virtual joystick with mouse

I am trying to implement a virtual joystick with the mouse. It needs to support sweeping gestures like an analog stick does. I feel like if I could force it to center each frame, this would be trivial. Is there a way to do this, or does anybody have suggestions? I tried just using raw mouse input, but it didn't feel intuitive for sweeping gestures.

Comment
Add comment · Show 4
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 robertbu · Jun 30, 2013 at 11:18 PM 0
Share

I'm not sure what mouse mechanic you are looking for, but the first thing I'd try is to set the 'Type' of movement for the 'Horizontal' and 'Vertical' axes to '$$anonymous$$ouse $$anonymous$$ovement' (Edit/Project Settings/Input). Then put this on a cube in a new scene:

 #pragma strict
  
  var speed = 1.0;
  
  function Update() {
      transform.Translate(Input.GetAxis("Horizontal") * speed * Time.deltaTime, Input.GetAxis("Vertical") * speed * Time.deltaTime, 0.0);
  }

Rather than centering the cursor, it calculates the delta movement every frame.

avatar image rocketeer13 robertbu · Jun 30, 2013 at 11:37 PM 0
Share

Sort of. This would work if I was interested in translating with the mouse, or if I was implementing freelook. I'm actually doing something like swinging an axe. On a gamepad, this is accomplished by making a rotating motion with an analog stick. On mouse, however, I can't make this feel natural. I think it is because every frame my reference point changes, unlike an analog stick where the reference point is always the same. If I could fix the mouse to a point, I could easily emulate controler feedback. Does that help?

avatar image robertbu · Jun 30, 2013 at 11:44 PM 0
Share

I've converted my answer to a comment. Why not make your reference point the start of cutting...on the mouse down or at whatever event starts the cutting motion?

avatar image rocketeer13 · Jul 01, 2013 at 12:08 AM 0
Share

That is the whole crux of the problem. I may end up doing that as a last resort, but I was hoping to just have this sit out there passively. $$anonymous$$aybe it will help if I give a little background on the application, it will help. I'm designing an experimental gameplay take on old-school Legend of Zelda. Basically, all user interaction will be analog. Want to swing a sword? Actually input a swing in the controls. Want to fire an arrow? You will have to pull back the draw string. In the sword scenario, I plan to have the sword just sticking out as people walk around, similar to the old Atari game Adventure. I want to passively listen to controler state to correctly orient the sword. On gamepad, this is accomplished by snapping the sword to a vector given by the orientation of the right analog stick. This supports a sweeping/swinging motion since all values are relative to a fixed reference point. If I required a mousedown event, I could do the same thing on mouse, I just wish there was a more passive way to do this.

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

15 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

Related Questions

How to make camera position relative to a specific target. 1 Answer

How could I use the mouse as input for a flight control system (and space bar for thrust!) 2 Answers

OnMouse menu 1 Answer

Check if mouse is down while in Edit Mode 1 Answer

having trouble with "ctrl + number" 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