• 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 rhose87 · Dec 21, 2011 at 07:37 AM · iphoneipadfirst-person-controllergyro

iphone/ipad Gyro perpendiculat and moving FPC

I am working on a project and i want my FPC to walk in a scene based on gyro input. My problem is that i don't know how to make it work perpendicular to the ground and not parallel.

I am using Input.gyro to look around me and for walking i am using the standard walking script with gyro.gravity as import and a GUI texture to enable/disable walking.

Looking around script is :

 function Update () {
 if (gyroBool  && !fpc.walk) {
     var camRot : Quaternion = gyro.attitude * rotFix;
     transform.localRotation = camRot;
 }
 }

Where gyroBool tests if the gyro is available and fpc.walk is checking if the walking arrow wasn't touch.

FPC walk :

 function FixedUpdate() {
 if (grounded) {
     moveDirection = new Vector3 (gyro.gravity.y, 0,gyro.gravity.x);
     moveDirection = transform.TransformDirection(moveDirection);
     moveDirection *= speed;
 }    // Apply gravity
 moveDirection.y -= gravity * Time.deltaTime;
 if (walk){// Move the controller
     var controller : CharacterController = GetComponent(CharacterController);
     var flags = controller.Move(moveDirection * Time.deltaTime);
     grounded = (flags & CollisionFlags.CollidedBelow) != 0;
 }
 }
 function Update() {
 if (Input.touchCount > 0){
     var touch = Input.GetTouch(0);
     if (touch.phase == TouchPhase.Began && arrow.HitTest(touch.position)){
         walk = true;
     }
     if (touch.phase == TouchPhase.Ended || touch.phase == TouchPhase.Canceled){
         walk = false;
     }
 }
 }

Any idea on how to make it walk standing ?

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
Best Answer

Answer by rhose87 · Jan 03, 2012 at 07:39 AM

I solve it by replacing the following line :

 moveDirection = new Vector3 (gyro.gravity.y, 0,gyro.gravity.x);

with :

 moveDirection = new Vector3 (gyro.gravity.y, 0,gyro.gravity.x+1);
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

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

Need to treat the input.gyro as a steering wheel on iPad 1 Answer

About iPhone/iPad development 1 Answer

does the iPad have a max FPS 2 Answers

translating a touchDeltaPosition from the y axis to z axis 1 Answer

condition `!mono_debug_initialized' not met 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