- Home /
Question by
DeathhGhost · Mar 05, 2014 at 08:42 PM ·
camerajavascripttransform
Pan Orthographic Camera
Hello, I have a 2d game. Its a side scroller. I need help trying to make my code only make it move to the side when im near the edge. not when I get side velocity which is everysecond
var howfartomovescreen : int = 0;
var velocity1 : Vector3 = Vector3.zero;
if(Input.GetAxis("Mouse X") < howfartomovescreen)
{
//Code for action on mouse moving left
velocity1.x -=1;
print("Mouse moved left");
}
if(Input.GetAxis("Mouse X") > howfartomovescreen){
//Code for action on mouse moving right
velocity1.x +=1;
print("Mouse moved right");
}
Camera.main.transform.Translate(velocity1);
Comment
Your answer
Follow this Question
Related Questions
Can someone help me fix my Javascript for Flickering Light? 6 Answers
Setting Scroll View Width GUILayout 1 Answer
Move an object toward an angle in 2d space 0 Answers
Camera, Offsetting the Transform.LookAt 2 Answers
Rotating An Object On Its Axis Once 3 Answers