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 /
  • Help Room /
This question was closed Dec 03, 2016 at 02:15 AM by Thomas-Hawk for the following reason:

I figured it out. :P

avatar image
0
Question by Thomas-Hawk · Dec 03, 2016 at 01:50 AM · scripting probleminputmathaxisaccelerometer

Acceleration input math problem.

Currently I have: The movement speed of my character is multiplied by a variable defined by the tilt acceleration + 1. So when I tilt the phone forward (beyond 0, where 0 is "sitting flat on a table") the movement speed increases.

What I want: The movement speed to increase, where the smallest value is when the accelerometor reports -1 (held upright in landscape left) and the greater values (increasing the movement speed more) when the accelerometer is closer to 0 (0 being "laying flat on a table", which relative to how most people hold their phone, is "tilted forward").

Mathematical dillema: Multiplying by absolute value does convert the tilt to affect the movement speed, but I'm still leaning the phone back to go faster, which isn't what I want.

I can add another 1 to the negative value but it still reports smaller values the closer it is to 0.

It sounds farfetched, but is there something I can do to sort of, invert the absolute value for what I'm trying to do?

     TiltModifier = Mathf.Abs(Input.acceleration.y) + 1;
     anim.SetFloat ("Tilt", TiltModifier);

     float movespeed = moveJoystick.InputDirection.z + (TiltModifier * 2);

     anim.SetFloat ("movespeed", movespeed - (TiltModifier * 2));


Comment
Add comment · Show 1
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 Thomas-Hawk · Dec 03, 2016 at 02:15 AM 0
Share

Never$$anonymous$$d! The solution was, and maybe verbosely, to define another variable, define it as -1 + the absolute value of the Y acceleration, and then define the tilt modifier variable as that value plus 1.

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

97 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

Related Questions

Problem with input axis "Submit" 1 Answer

Custom input not appearing in input manager 0 Answers

Google Cardboard Look Axis are the Opposite. 0 Answers

I am showing double on screen and it disappear 1 Answer

Having terrible trouble with GUIText 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