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 ma22be61 · May 12, 2017 at 11:33 PM · touchtouch controlsstandard-assetsstandard assets

Set the move touchpad (in DualTouchControls , Standard Assets) moving direction relative to the player rotation

Let me explain the problem.

  • I got a camera that rotates around the player;

  • I move the player using the move touchpad which is included in Standard Assets (in dualtouchcontrols)

  • Everything works but if the player rotates a full 180* the controls on the touchpad are the same. For example if I wanna go down I have to press the same button but , having the camera rotated 180* , it seems that I'm pressing the up button.

What I really want is a system in which the move touchpad direction is relative to the player rotation

Comment
Add comment · Show 5
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 RobAnthem · May 13, 2017 at 12:18 AM 1
Share

The touchpads just calculate your movement on the area and pass it into the input axis.

Something like this might be what you are looking for.

 public Rigidbody body;
 public float speed;
 private float vertical;
 void FixedUpdate()
 {
     vertical = Input.GetAxis("Vertical");
     body.velocity = transform.forward * speed * vertical  * Time.fixedDeltaTime;
 }
avatar image ma22be61 RobAnthem · May 13, 2017 at 10:25 AM 0
Share

So you suggest putting the Vertical axis into an update function?

avatar image ma22be61 RobAnthem · May 13, 2017 at 10:41 AM 0
Share

Sorry , there was a misunderstanding. (by me)

I got the following code

 void FixedUpdate ()
 {
     //$$anonymous$$ovement and rotation towards the movement direction
     vertical = CrossPlatformInput$$anonymous$$anager.GetAxisRaw ("Vertical");
     horizontal = CrossPlatformInput$$anonymous$$anager.GetAxisRaw ("Horizontal");
     Vector3 playermovement  = new Vector3 (horizontal,0f, vertical);
     playerbody.AddForce (playermovement*speed);
 }

It is using the default assets touch pad (as you know). I tried creating the body.velocity but it didn't work. By the way this is the player movement script , not the touchpad .

avatar image RobAnthem · May 15, 2017 at 01:03 AM 0
Share

Forgot to mention, quickest solution would be to rotate the pad with the player, or alternatively calculate the movements relative to the rotation.

avatar image ma22be61 RobAnthem · May 15, 2017 at 11:24 AM 0
Share

Tried to rotate the pad but it doesn't work. It will just remain the same (in the movement).

How could I calculate the movements relative to the rotation? I thought about using only the horizontal axis (in playermovement) and , once the horizontal axis is activated , vertical = 1.

Vertical will use the playercamera.transform.rotation.y... What do you think?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by ma22be61 · May 13, 2017 at 11:11 PM

I will explain my problem a bit better. I got a touch pad which moves the player around correctly. The problem is that , when the camera rotates , the touchpad doesn't get "updated" and rather than going forward the rotation of the camera it just does the same thing independently.

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 ma22be61 · May 14, 2017 at 09:44 PM 0
Share

any 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

86 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

Related Questions

How do I use the mobile "DualTouchControls"? 1 Answer

Cross Platform Input Controller Not Working on Mobile Device 2 Answers

Touch.ScreenPosition doesnt work ? 0 Answers

CrossPlatformInputManager.GetAxis() always returns 0 5 Answers

How to get intermediate swipe positions? 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