- Home /
Camera movement performs different with different inputs
Hello! Im am creating game map which is seen from 90degrees above. (The game is on Android).The camera has a script which gets user input and pans(moves x,y) the camera on map. Problem is that when I test in Editor with mouse I get the expected performance - everything works great, lerp etc.. But when I test in Android device with touch, the performance is like jumping around and lerp is not working. What is the problem?
private var yaxis:float;
private var xAxis:float;
private var vertSpeed:float;
private var horiSpeed:float;
public var rotationSpeed: float;
public var lerpSpeed: float;
public var krabis:GUIText;
var cameraTopLimit: float;
var cameraBottomLimit:float;
var cameraTopLimit2: float;
var cameraBottomLimit2:float;
function Update () {
if(Input.GetMouseButton(0) ) {
yaxis = -Input.GetAxis("Mouse Y");
vertSpeed = yaxis;
xAxis = Input.GetAxis("Mouse X");
horiSpeed = xAxis;
}
else {
var ix = Time.deltaTime * lerpSpeed;
vertSpeed = Mathf.Lerp(vertSpeed, 0, ix);
horiSpeed = Mathf.Lerp(horiSpeed, 0, ix);
}
var limitY = Mathf.Clamp(transform.position.x + (vertSpeed * rotationSpeed), cameraBottomLimit, cameraTopLimit);
transform.position.x = limitY;
var limitX = Mathf.Clamp(transform.position.z + (horiSpeed * rotationSpeed), cameraBottomLimit2, cameraTopLimit2);
transform.position.z = limitX;
krabis.text = ": " + yaxis;
}
Thanks!
I'm not sure of the cause of your problem, but to simulate the behaviour on the Android device, have you considering using http://docs.unity3d.com/ScriptReference/Application-targetFrameRate.html to slow down the Editor version?
Your answer
Follow this Question
Related Questions
How to smooth my camera (Vector3.Lerp) 0 Answers
Problems with Lerp. 1 Answer
Problem with First-Person-Control and Quaternion.Lerp 0 Answers
Camera Zoom script stops ability to pan 1 Answer
MouseWheel Lerp Smoothing Problem 1 Answer