Alright, I’ve got a problem with my joystick. I’m an adept programmer but this is my first project working on an IOS application and I just can’t find out how to fix the problem. Here is the function that controls the ships movement:
public void MoveShipJoystickFixedUpdate() {
rigidbody.AddRelativeForce(0, 0, normalizedSpeed * forwardForce);
Vector3 accelerator = _joystick.transform.position;
// Rotate turn based on acceleration
euler.y += accelerator.x * turnSpeed;
// Since we set absolute lean position, do some extra smoothing on it
euler.z = Mathf.Lerp(euler.z, -accelerator.x * maxTurnLean, 0.2f);
// Since we set absolute lean position, do some extra smoothing on it
euler.x = Mathf.Lerp(euler.x, accelerator.y * maxTilt, 0.2f);
// Apply rotation and apply some smoothing
Quaternion rot = Quaternion.Euler(euler);
transform.rotation = Quaternion.Lerp (transform.rotation, rot, sensitivity);
}
I didn’t find anything wrong with that but it ties in closely with the Joystick script. Of which I got from the Unity Wiki: http://wiki.unity3d.com/index.php/Joystick. I need to know how to tie into my movement script. It apparently doesn’t change the position of the GameObject, it seems that is only changes the pixel inset location of the joystick texture? It needs to give a value between -1 and 1. Is there some way I can get the movement of the joystick to return between those values? Any advice is greatly appreciated but you’ll need to take a glance at the Joystick.cs to understand what I’m saying.