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 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 touching the screen of the phone.(it does this automatically, I didn't script it that way) I don't want to control the player movements by touching 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 which is attached to my Main camera. I have a child object attached to the camera which 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 this script to fix this problem? thanx

// Performs a mouse look.

var horizontalSpeed : float = 2.0;

var verticalSpeed : float = 2.0;

function Update () {

// Get the mouse delta. This 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
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

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

If you want to move the device to contol something 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 this helps,

Cheers Chris

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

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

Input for Android 2 Answers

2D Torque rotation - stop at certain angle 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