CodePudding user response:
if (Input GetKeyDown (KeyCode. UpArrow)) {lens forward code}
The same KeyCode. DownArrow KeyCode. LeftArrow KeyCode. RightArrow
CodePudding user response:
Camera movement code
GameObject _mainCamera;
Vector3 Vec3;
Int DIRFlag;
Int Vect;
//Use this for initialization
Void the Start ()
{
DIRFlag=1;
Vect=1;
Vec3=new Vector3 ();
MainCamera _mainCamera=GameObject. FindWithTag (" ");
}
//Update is called once per frame
Void the Update ()
{
Vec3=_mainCamera. The transform. The position;
If (Input. GetKeyDown (KeyCode. UpArrow))
{
Vect +=1;
}
If (Input. GetKeyDown (KeyCode. DownArrow))
{
If (Vect & gt; 0)
{
Vect -=1;
}
}
//
If (Input. GetKeyDown (KeyCode. W))
{
DIRFlag=0;
}
If (Input. GetKeyDown (KeyCode. S))
{
DIRFlag=1;
}
If (Input. GetKeyDown (KeyCode. D))
{
DIRFlag=2;
}
If (Input. GetKeyDown (KeyCode. A))
{
DIRFlag=3;
}
If (DIRFlag==0)
{
Vec3 +=new Vector3 (Vect, 0, 0);
}
Else if (DIRFlag==1)
{
Vec3 -=new Vector3 (Vect, 0, 0);
}
Else if (DIRFlag==2)
{
Vec3 +=new Vector3 (0, Vect, 0);
}
Else if (DIRFlag==3)
{
Vec3 -=new Vector3 (0, Vect, 0);
}
_mainCamera. The transform. The position=Vec3;
}