• 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
Question by DFiable · Aug 21, 2011 at 05:19 AM · androidrotationtouchaxis

Alternate command for rotation on Android ?

I have a first person tunnel game where the player is always in forward motion. When I play the game on the PC or the Web, I control movement by moving my mouse back and forth to rotate the camera 360 degrees around the z axis. When I play the game on the Android phone, I can only move the main player(rotate on z axis) by touc$$anonymous$$ng the screen of the phone.(it does t$$anonymous$$s automatically, I didn't script it that way) I don't want to control the player movements by touc$$anonymous$$ng the screen, I want to move the phone to control the player. Can someone point me in the right direction? I don't even know where to start. Thanx

Here is my rotation script w$$anonymous$$ch is attached to my Main camera. I have a c$$anonymous$$ld object attached to the camera w$$anonymous$$ch is the main player object.(Sphere) When I move the mouse the sphere moves with the camera as it rotates 360 degrees. What commands do I need to add to t$$anonymous$$s script to fix t$$anonymous$$s problem? thanx

// Performs a mouse look.

var horizontalSpeed : float = 2.0;

var verticalSpeed : float = 2.0;

function Update () {

// Get the mouse delta. T$$anonymous$$s is not in the range -1...1

var h : float = horizontalSpeed * Input.GetAxis ("Mouse X");

var v : float = verticalSpeed * Input.GetAxis ("Mouse Y");

transform.Rotate (v, 0, h); }

Comment

People who like this

0 Show 0
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

1 Reply

· Add your reply
  • Sort: 
avatar image

Answer by em2 · Aug 21, 2011 at 05:40 AM

If you want to move the device to contol somet$$anonymous$$ng you will have to tap into the accelerometer. A good example is the roll-a-ball example and tilt functions. Check out the Input class and acceleration i.e. Input.acceleration. Hope t$$anonymous$$s helps,

Cheers Chris

Comment

People who like this

0 Show 3 · 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 em2 · Aug 21, 2011 at 05:44 AM 0
Share

Have a look in the standard assets (mobile) > scripts, for an example of implementation.

avatar image DFiable · Aug 21, 2011 at 12:57 PM 0
Share

thank you.....

avatar image em2 · Aug 21, 2011 at 01:41 PM 0
Share

You're welcome. Chris

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

Replace Input.GetAxis with Touch 2 Answers

Stopping rotation at 90° and -90°/270°. 0 Answers

Converting Android Axis to Unity Axis 0 Answers

How do you map touch points to world space? 1 Answer

Moving an Object to the position of touch 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