• 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 alan317317 · Jul 14, 2014 at 03:34 PM · controllerrelative position

Player moves relatively to the controller position

I have a touch screen controller that allows player to scroll horizontally. It works well.

However, I'm struggling using this controller to move the player relatively to the horizontal control bar.

This is my thought: A controller that scrolls horizontally, left and right. (A cube when you touch and drag it, it moves) If I scale this controller to match the screen size, the control icon is like the player that moves horizontally. (so now the cube looks like the player sprite size, but I have to touch and drag on it to make it moves). The thing is, I want to use a controller to control the movement. I don't want the player to touch the gameobj directly.

How do I link a relatively small controller to the player so that the player can move across the screen?

If I simply parent the player under the controller cube, when I move the controller cube (joystick), the player does move with it. However, the player only has the exactly displacement as the joystick. If the joystick reaches to the far end of the controller range, the player stops.

I want the player to -- if I move the controller cube to the end of the bar, the player should be at the end of the screen. If I move the controller cube to the middle of the bar, the player should appear center on the screen.

Please help!! Thank you!

Comment
Add comment · Show 2
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 Tyyy1997 · Jul 14, 2014 at 07:26 PM 0
Share

So what your saying is, you have a joystick, and when you move the joystick, you want the player to match the location on the screen that the joystick is at relative to it's base? If this is the case, you should find a way to capture the input values of the joystick position, however it's setup, then translate those through some method of yours to world space. Of course, I'm having a hard time understanding what you mean, so this may have nothing to do with your problem.

avatar image alan317317 · Jul 15, 2014 at 03:39 PM 0
Share

Thanks for replying @Tyyy1997! Yes, you are right, I'm trying to match them relatively to the joystick base and after spending hours on this issue, I think I'm on a right track!

I did some basic algebra ratio stuff, calculate the player displacement ratio, and set the player movement relatively to that... and seems like i'm on a right track haha

However, if you have time, would you explain more of your approach to this problem?

Thanks for helping out!

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

MMD How to export model and animations to Unity as 3rd person controller? 2 Answers

OnControllerColliderHit works on 2 character controllers 0 Answers

How do you properly deal with analog joystick input on multiple controller inputs? 1 Answer

Check CharacterController's Velocity 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