I got a touch panel in which there is the TouchPad script (form Unity Standard Assets) . This script only allows the horizontal axis to be changed (min is -1 and max is 1). I want to change a float value (smoothly) to -180 when at minimum and 180 when at maximum. This variable is used in a camera rotation script (which works fine).
How can I do this?
Nevermind , I got it. It was simpler than I thought.
All you have to do is check if the horizontal axis is greater or lower than 0. A script example down here.
using System.Collections;
using System.Collections.Generic;
using UnityStandardAssets.CrossPlatformInput;
using UnityStandardAssets.Utility;
using UnityEngine;
public class increaseNumByTouch: MonoBehaviour {
float horizontal;
float thenumberyouwanttoincrease;
void Update () {
horizontal = CrossPlatformInputManager.GetAxis ("Horizontal");
if (horizontal > 0) {
thenumberyouwanttoincrease += 5;
} else if (horizontal < 0) {
thenumberyouwanttoincrease += -5;
}
}
}