- Home /
Apple like camera Panning(Finding mouse speed and apply it to camera)
Does any body know how to make a smooth pan based on the speed of the mouse. its for an overhead type strategy game. i have been trying to work on it for a while heres my code so far (p.s. its a bit messy):
// Dont have to read its just a reference
var startingMousePosition : Vector3;
var x;
var y;
var usingGUI : GuiStart;
var xSpeed;
var ySpeed;
var xZero;
var yZero;
function Update () {
var time = Time.fixedTime;
usingGUI = GetComponent(GuiStart);
if(usingGUI.isGui == false){
Debug.Log(usingGUI.isGui);
if(Input.GetMouseButtonDown(0)){
x = transform.position.x;
y = transform.position.z;
}
if(Input.GetMouseButton(0)){
xZero = Input.mousePosition.x;
yZero = Input.mousePosition.y;
xSpeed = (xZero/time)* .1;
ySpeed = (yZero/time)* .1;
x -= Input.GetAxis("Mouse X")*.1;
y -= Input.GetAxis("Mouse Y")*.1;
transform.position.x = x;//+xSpeed;
transform.position.z = y;//+ySpeed;
//Debug.Log(x + " " + y);
}
Debug.Log("This is x's Speed: " + xSpeed);
Debug.Log("This is y's Speed: " + ySpeed);
//Debug.Log(time);
//Debug.Log(x + "and Y: " +y);
}
}
but here is what i want it to do, i want it to find the starting point of the camer( to zero it out) and then add the mouses speed to the cameras tranform, but i dont know how to find the mouses speed at all. and then if i could find the mouses speed how would i stop the camera after a bit?
Your answer
Follow this Question
Related Questions
How do I rotate a character with my mouse? 1 Answer
Pan an isometric ortho camera 2 Answers
Position icon lags while panning 1 Answer
Camera rotate with mouse in TPC 0 Answers
I'm having problems with running my game on Ubuntu/Linux. 2 Answers