Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 _1 · Feb 15, 2014 at 03:37 AM · movementinputissuexbox

Xbox movement issue

Hi there, I am a noob at unity and I just started xbox programming in unity and I watched this tutorial

xbox tutorial

The issue is that my character continuously moves forward after I touch a joystick and the camera can only move up and down, say if you touch the Camera joystick to the left or right it will not move. I would like it so if you touch the joystick to the right or left the camera will move in that direction. Sorry if that's confusing. Here's the code from the tutorial.

pragma strict

 var speed = 10;
 var rotatespeed = 5;
 var cam : Transform;
 
 function Update () {
 
 var amtToRotate = rotatespeed * Input.GetAxis("VerticalRight") * Time.smoothDeltaTime;
 var amtToRotateVert = rotatespeed * Input.GetAxis("HorizontalRight") * Time.smoothDeltaTime;
 var amtToMove = -speed * Input.GetAxis("Vertical") * Time.smoothDeltaTime;
 var amtToSideStep = speed * Input.GetAxis("Horizontal") * Time.smoothDeltaTime;
 
 transform.Translate(Vector3.forward * amtToMove);
 transform.Translate(Vector3.right * amtToSideStep);
 transform.Rotate(Vector3.up, amtToRotate);
 cam.Rotate(Vector3.left, amtToRotateVert);
 
 
 }   


heres the buttons in the input manager

alt text alt text

I am using a mac OSX, I don't know if that makes a difference.

Thanks I appreciate all the help for I am a noob :)

screen shot 2014-02-14 at 9.17.44 pm.png (61.4 kB)
screen shot 2014-02-14 at 9.24.40 pm.png (60.7 kB)
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 erick_weil · Feb 15, 2014 at 03:51 AM

 add a rigidybody to your character and use this code to move:

 var speed = 10;
 var rotatespeed = 5;
 var cam : Transform;
  
 function Update () {
  
 var amtToRotate = rotatespeed * Input.GetAxis("VerticalRight") * Time.smoothDeltaTime;
 var amtToRotateVert = rotatespeed * Input.GetAxis("HorizontalRight") * Time.smoothDeltaTime;
 var amtToMove = -speed * Input.GetAxis("Vertical");
 var amtToSideStep = speed * Input.GetAxis("Horizontal");                
 
 
                 // to move foward
             transform.rigidbody.velocity.z = (amtToMove *transform.forward.z);
             transform.rigidbody.velocity.x = (amtToMove *transform.forward.x);
                 // to move at side
             transform.rigidbody.velocity.x += (amtToSideStep*transform.right.x);
             transform.rigidbody.velocity.z += (amtToSideStep*transform.right.z);
 
 transform.Rotate(Vector3.up, amtToRotate);
 cam.Rotate(Vector3.left, amtToRotateVert);
 
 
     
Comment
Add comment · Show 1 · 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 _1 · Feb 15, 2014 at 04:44 AM 0
Share

still moves forward even if not touching joystick.

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

19 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

Related Questions

Right Analog Stick not mapping 0 Answers

New Input System 'Started' and 'Performed' actions fire at the same time? 1 Answer

Problem with input code for a camera follow/rotate script 0 Answers

Xbox one controller support? 3 Answers

Shooting in direction of the character movement 2 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