I have a simple script that lets my object (sphere) copy the moves of the stick of my Xbox 360 gamepad. It just emulates the stick: if I tilt it a little, my sphere moves a bit; if I release it, it goes back to origin. That
s perfect, that`s exactly what I need.
using UnityEngine;
using System.Collections;
public class Move : MonoBehaviour {
public Transform target1;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void FixedUpdate () {
transform.LookAt (target1);
transform.position = new Vector3 (Input.GetAxis ("Horizontar"), transform.position.y, transform.position.z);
transform.position = new Vector3 (transform.position.x, transform.position.y, - Input.GetAxis ("Verticar"));
}
}
Now, what I want my sphere is to make the same moves, but LOCALLY, not necessarily returning to origin. I don`t know how to do that. With the script I showed you the sphere is always set at origin, when I start the game — no matter where I placed it in the editor.
Any help is appreciated.
Thanks.