- Home /
problems moving game object with the right joystick
Hi, I'm having a problem setting up my game project with controller support. I control a character's speed with the left joystick which works fine, but I control the character's orientation by having him move towards a target object that I want to move with the right joy stick. I attempt to move the target object with the following code, but it results with me only being able to move the target object horizontally by moving the joystick on the 5th axis, and not at all on the 4th axis. I tried switching the axis to button inputs on the keyboard and they work fine that way, which baffles me a bit.
Update: Alright, I'm noticing that it will only register input from the 4th axis, but it will only register input from the 4th axis if I move the stick from the 5th axis
using UnityEngine; using System.Collections;
public class Xbox_Cursor : MonoBehaviour { public Rigidbody xbox_clicker; public float mouse_sense;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
xbox_clicker.AddForce(transform.right * mouse_sense * Input.GetAxis("Horizontal_R"));
xbox_clicker.AddForce(transform.forward * mouse_sense * Input.GetAxis("Vertical_R"));
} }
this is what my input manager looks like
forgive me, I have a feeling this is a dumb question, but I'm having trouble finding an answer.
$$anonymous$$ade sure mouse_sense is not 0? Would also do a Debug.Log test to check values of the two Input.GetAxis
Yeah mouse_sense is set to 20. When I do a debug.log only Horizontal_R seems to be getting updated, but I have no idea why.
void Update () {
rigidbody.AddForce(transform.right * mouse_sense * Input.GetAxis("Horizontal_R"));
rigidbody.AddForce(transform.forward * mouse_sense * Input.GetAxis("Vertical_R"));
}
Worked for me using same input settings as you. Any chance xbox_clicker could be set to another rigidbody than the one on the object?
Double check that there not two Vertical_R in the input settings. Disconnect and connect the controller. Try the controller on another game or somehow check that it works. Try another USB.
thanks, there is only one vertical_R in the input settings and I double checked and the rigid body for xbox clicker is correct. The controller isn't broken as I get the same thing with several different ones. Could this have something to do with me being on a mac?
Answer by FunFreighterGames · Oct 21, 2014 at 09:42 PM
Alright, I figured it out. So apparently the inputs for the xbox controllers for Mac is different for those on PC. I don't know why I didn't think of this hours ago, but here is a link to what the Mac inputs are http://answers.unity3d.com/storage/attachments/7661-unity_360controller_mac_layout.png. Tell your friends.
Your answer
Follow this Question
Related Questions
Getting Raw Joystick Input via Script 1 Answer
Gamepad input, axis OR button 0 Answers
Controlling MouseLook script with keys/joystick 1 Answer
Unity ignoring joysticks of specified number 0 Answers
First Person Controller Erratic 1 Answer