• 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 D3m0nE · Mar 15, 2015 at 10:32 AM · androidfpsrotateacceleration

Mobile Tilt Problem

Hello, i'm creating FPS game for mobile but i have little problem in my code that if i want to look right or left i must tilt the phone like the Car Steering wheel i dont need it that way i want to rotate the phone in x axis

sorry my english is bad this photo may explain what i want

alt text

 rotationX +=  Input.acceleration.x   * sensitivityX;
             rotationX = Mathf.Clamp (rotationX, minimumX, maximumX);
             
         //    transform.localEulerAngles = new Vector3(0,rotationX, 0);
             transform.rotation = Quaternion.Euler(0, rotationX, 0.0f);


i hope someone can help me or guide me to the right way

hello.png (20.5 kB)
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 D3m0nE · Mar 17, 2015 at 08:45 AM 0
Share

any help?

avatar image alok-kr-029 · Mar 17, 2015 at 10:27 AM 0
Share

I dont think so you need to clamp it just add the transform to the current transform if you are getting the correct input from the user

I remember what I did was change the accleration of the mobile to angle and took the input .

avatar image D3m0nE · Mar 19, 2015 at 10:24 PM 0
Share

@alok.kr.029

can you tell me more info please or tell me what i should google

because its first time dealing with mobile stuff and i must fix this issue ,

Thanks

avatar image smallbit · Mar 21, 2015 at 06:11 AM 0
Share

did you try to use y axis instead of x?

avatar image alok-kr-029 · Mar 21, 2015 at 07:34 AM 0
Share

To look around wont it be better if you use gyro scope but if you still want to use accleratometer check the link given below it will help you

http://stackoverflow.com/questions/23871599/what-does-x-y-z-values-obtained-from-accelerometer-in-android-indicate

actually its been a long time , if you still have problem let me know.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Priyanshu · Mar 21, 2015 at 07:19 AM

This video might help you.

Check out this Unity Question as well.

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

24 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

Related Questions

Rotate Camera using Accelerometer 0 Answers

i have a fps sniper game and it runs slow on the tablet 1 Answer

Input Acceleration Z always -1 0 Answers

A few android questions. 0 Answers

Mobile FPS Help 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges