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
1
Question by H-VISION · Mar 17, 2013 at 09:10 PM · c#rotationaccelerometertilt

Using the accelerometer as controller on android.

Hi,

I am a designer and can program somewhat in Unity, but I'm absolutely new in programming for the mobile. I'm trying to create a FPS game using the accelerometer/gyroscope function as a controller. I looked for any tutorials on this matter, but there aren't many to almost none. What I want to do is when you are in idle position and move the phone forward on the z-axis, you will automatically walk forward when you reached a certain amount of force forward. Same goes for walking backwards. When you want to go back to idle position, you just the phone the opposite direction. So from walking, move the phone backwards to stand still and vice versa for walking back.

To look up you have to pitch and move the phone up and to look down, you have move your phone down and pitch down.

To rotate to the left with a steady speed happens if you yaw the phone to the left about 20 degrees and rotate right by yawing the phone to the right.

Anyone who could help me with this is much appreciated.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by nsxdavid · Mar 18, 2013 at 05:29 AM

You can measure accelerations, not absolute positions in 3D space.

The Input class provides acceleration events and data.

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 H-VISION · Mar 18, 2013 at 05:26 PM 0
Share

Yes I understand that, but even if I move the phone forwards, the accelerometer should pick up acceleration in the z-axis right? So let's say I move the phone forward with a force of 2 g, it should be possible to say: When z-axis force is equal or higher than 2 g, walkspeed is 10.0f. You can keep on walking until you move your phone back again with a force of -2 g. It should be possible right? As long as the gravity on the y -axis doesn't change too much.

avatar image H-VISION · Mar 19, 2013 at 12:30 PM 0
Share

No I think misunderstand what I am saying. I am not talking about physically walking to make your character walk. Just moving your phone forward, like a nudge. I did some test with an app that registers changes in accelerations with the accelerometer. If you hold the phone in front of you with the screen facing you and the button down, you see that gravity has an effect on the y-axis; around -10g. If you nudge your phone forward in the z-axis you change see some changes, first a negative acceleration and then a positive acceleration.

Problem however if you pitch the phone it will also change acceleration in the z-axis. On the other hand there will also be changes in the y-axis. But when you nudge the phone forward, there are little changes in the y-axis.

So shouldn't it be possible to register a nudge forward as an action? And when that action is performed, automatically walk. Not for just the nudge you did, you walk. So a nudge forward is auto walk forward, a nudge back you return to idle stance.

I have read a lot of articles about it and yes I understand what it is for, because that is the intended use for it. But I am trying to think out of the box here and theoretically it should be possible to do it, albeit difficult I imagine.

avatar image
0

Answer by unity_HXWyAuxDnZ3OHw · Sep 15, 2021 at 01:16 PM

have you found anything? i know it has been a while, but i am trying to do the same thing without success

Comment
Add comment · 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

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

13 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

Related Questions

Flip over an object (smooth transition) 3 Answers

Distribute terrain in zones 3 Answers

Multiple Cars not working 1 Answer

Smooth tilt accelerometer 1 Answer

Smooth Accelerometer tilt rotation 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