- Home /
Question by
keimax1981 · Jun 17, 2017 at 10:31 AM ·
lean
Leantouch RTS Camera Movement on a plane
Hi,
I am using the leantouch asset and use a script to move (drag) the camera. Since its an rts like game, i rotated the camera on the x axis by 50 degrees to face a ground plane. Now, the dragging is off since the rotation is not considered. What Do I have to do to fix this?
This is the original script: using UnityEngine;
namespace Lean.Touch { // This modifies LeanCameraMove to be smooth public class LeanCameraMoveSmooth : LeanCameraMove { [Tooltip("How quickly the zoom reaches the target value")] public float Dampening = 10.0f;
private Vector3 remainingDelta;
protected override void LateUpdate()
{
// Store the current position
var oldPosition = transform.localPosition;
// Call LeanCameraMove.LateUpdate
base.LateUpdate();
// Add to remainingDelta
remainingDelta += transform.localPosition - oldPosition;
// Get t value
var factor = LeanTouch.GetDampenFactor(Dampening, Time.deltaTime);
// Dampen remainingDelta
var newDelta = Vector3.Lerp(remainingDelta, Vector3.zero, factor);
// Shift this position by the change in delta
transform.localPosition = oldPosition + remainingDelta - newDelta;
// Update remainingDelta with the dampened value
remainingDelta = newDelta;
}
}
}
Comment