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 siddharth3322 · May 07, 2016 at 03:29 PM · iostouch controlsaccelerometerappletv

Player Movement in Apple TV

I want to publish my game for apple tv. My game contains two types of player movement but at present nothing running via tv remote. I can't able to move my player using remote control. Same code words perfectly work for iOS version of game.

My first player movement code using touch:

 void Update ()
     {
         MoveBirdOnXAxis ();
 
         if (Input.GetMouseButtonDown (0))
             swatAreaDetected = IsSwatTouchArea ();
         else if (Input.GetMouseButton (0) && !swatAreaDetected) {
             flameObj.SetActive (true);
             BoostOnYAxis ();
         } else if (Input.GetMouseButtonUp (0)) {
             flameObj.SetActive (false);
             swatAreaDetected = false;
         }
 
         FixBabyGrayRotation ();
     }
 
     private bool IsSwatTouchArea ()
     {
         Vector3 pos = Camera.main.ScreenToWorldPoint (Input.mousePosition);
         RaycastHit2D hit = Physics2D.Raycast (pos, Vector2.zero);
         if (hit != null && hit.collider != null && hit.collider.CompareTag (GameConstants.TAG_SWAT_TOUCH_AREA))
             return  true;
         
         return false;
     }
 
     void MoveBirdOnXAxis ()
     {
 //        transform.position += new Vector3 (Time.deltaTime * horzSpeed, 0, 0);
         Vector2 currVelocity = myRigidBody.velocity;
         currVelocity.x = horzSpeed;
         myRigidBody.velocity = currVelocity;
     }
 
     void BoostOnYAxis ()
     {
         Vector2 currVelocity = myRigidBody.velocity;
         currVelocity.y = velPerJump;
         myRigidBody.velocity = currVelocity;
 //        myRigidBody.velocity = new Vector2 (0, velPerJump);
     }

My second player movement code using accelerometer:

 void Start ()
     {
         initalAccel = Input.acceleration;
     }
 
     void Update ()
     {
         FixBuddyRotation ();
     }
 
     void FixedUpdate ()
     {
         Vector3 accel = (Input.acceleration - initalAccel);
         Vector2 appliedAccelVel = new Vector2 (accel.x, -accel.z);
 
         if (Mathf.Abs (accel.x) > horzEliminationValue)
             appliedAccelVel.x = horzSpeed * Mathf.Sign (appliedAccelVel.x);
         else
             appliedAccelVel.x = myRigidBody.velocity.x * 0.6f;
 
         if (Mathf.Abs (accel.z) > vertEliminationValue)
             appliedAccelVel.y = vertSpeed * Mathf.Sign (appliedAccelVel.y);
         else
             appliedAccelVel.y = myRigidBody.velocity.y * 0.6f;
 
 
         if (appliedAccelVel.x < 0f && applyBackwardThrust) {
             applyBackwardThrust = false;
             appliedAccelVel.y = 0;
             appliedAccelVel.x *= 1.5f;
             Vector3 currVel = myRigidBody.velocity;
             currVel.y = 0;
             myRigidBody.velocity = Vector2.Lerp (currVel, appliedAccelVel, 1f);
         } else
             myRigidBody.velocity = Vector2.Lerp (myRigidBody.velocity, appliedAccelVel, Time.deltaTime * 5f);
 
         if (appliedAccelVel.x > 0f)
             applyBackwardThrust = true;    
     }

Above two are different approaches, but none of above is working. Via remote I can't able to move players. So what changes I need to do in above so that I can able to move my players.

Comment
Add comment · Show 11
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 siddharth3322 · May 13, 2016 at 01:13 PM 0
Share

Any suggestion in this? Still I can't able to figure this out.

avatar image meat5000 ♦ siddharth3322 · May 13, 2016 at 01:17 PM 0
Share

Youve read this page and all the links that are in it?

https://developer.apple.com/tvos/human-interface-guidelines/remote-and-controllers/

avatar image siddharth3322 meat5000 ♦ · May 13, 2016 at 01:19 PM 0
Share

@meat5000, I already gone through that document but in C# how can I move my player?

Show more comments
Show more comments
avatar image meat5000 ♦ siddharth3322 · May 13, 2016 at 04:05 PM 0
Share

I've never used Apple TV either. The page I linked you says so :P

https://developer.apple.com/library/tvos/documentation/ServicesDiscovery/Conceptual/GameControllerPG/Introduction/Introduction.html

avatar image siddharth3322 meat5000 ♦ · May 14, 2016 at 05:38 PM 0
Share

@meat5000, Game Controller is different thing, I have only Siri Remote only.

Show more comments

0 Replies

· Add your reply
  • Sort: 

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

54 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 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 avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

tvOS On Demand Resources: Unable to open archive file 0 Answers

PlayFullscreenMovie on AppleTV 0 Answers

Animation issues with Apple TVos 0 Answers

Implement Apple TV ODR (On Demand Resources)? 1 Answer

tvOS Icon sizes 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