###Rotate()
Rotate()
In this method the only difference between the if
branches are the getting of the X
and Y
location. It would be enough to place getting these in the branches and therefor you could remove some of the duplicated code but it would be much better just assigning the string
's, which are needed, to two variables like so
var xKey = "Mouse X";
var yKey = "Mouse Y";
if(this.UseController)
{
xKey = "Xbox Look X";
yKey = "Xbox Look Y";
}
this.transform.Rotate(new Vector3(0.0f, Input.GetAxis(xKey), 0.0f) * this.CameraRotationSpeed.x * Time.deltaTime);
this.VerticalRotation += Input.GetAxis(yKey) * this.CameraRotationSpeed.y * Time.deltaTime;
this.VerticalRotation = Mathf.Clamp(this.VerticalRotation, this.CameraRotationConstraints.x, this.CameraRotationConstraints.y);
Camera.main.transform.eulerAngles = new Vector3(
-this.VerticalRotation,
Camera.main.transform.eulerAngles.y,
Camera.main.transform.eulerAngles.z
);
###Rotate()
In this method the only difference between the if
branches are the getting of the X
and Y
location. It would be enough to place getting these in the branches and therefor you could remove some of the duplicated code but it would be much better just assigning the string
's, which are needed, to two variables like so
var xKey = "Mouse X";
var yKey = "Mouse Y";
if(this.UseController)
{
xKey = "Xbox Look X";
yKey = "Xbox Look Y";
}
this.transform.Rotate(new Vector3(0.0f, Input.GetAxis(xKey), 0.0f) * this.CameraRotationSpeed.x * Time.deltaTime);
this.VerticalRotation += Input.GetAxis(yKey) * this.CameraRotationSpeed.y * Time.deltaTime;
this.VerticalRotation = Mathf.Clamp(this.VerticalRotation, this.CameraRotationConstraints.x, this.CameraRotationConstraints.y);
Camera.main.transform.eulerAngles = new Vector3(
-this.VerticalRotation,
Camera.main.transform.eulerAngles.y,
Camera.main.transform.eulerAngles.z
);
Rotate()
In this method the only difference between the if
branches are the getting of the X
and Y
location. It would be enough to place getting these in the branches and therefor you could remove some of the duplicated code but it would be much better just assigning the string
's, which are needed, to two variables like so
var xKey = "Mouse X";
var yKey = "Mouse Y";
if(this.UseController)
{
xKey = "Xbox Look X";
yKey = "Xbox Look Y";
}
this.transform.Rotate(new Vector3(0.0f, Input.GetAxis(xKey), 0.0f) * this.CameraRotationSpeed.x * Time.deltaTime);
this.VerticalRotation += Input.GetAxis(yKey) * this.CameraRotationSpeed.y * Time.deltaTime;
this.VerticalRotation = Mathf.Clamp(this.VerticalRotation, this.CameraRotationConstraints.x, this.CameraRotationConstraints.y);
Camera.main.transform.eulerAngles = new Vector3(
-this.VerticalRotation,
Camera.main.transform.eulerAngles.y,
Camera.main.transform.eulerAngles.z
);
###Rotate()
In this method the only difference between the if
branches are the getting of the X
and Y
location. It would be enough to place getting these in the branches and therfortherefor you could remove some of the duplicated code but it would be much better just assigning the string
's, which are needed, to two variables like so
var xKey = "Mouse X";
var yKey = "Mouse Y";
if(this.UseController)
{
xKey = "Xbox Look X";
yKey = "Xbox Look Y";
}
this.transform.Rotate(new Vector3(0.0f, Input.GetAxis(xKey), 0.0f) * this.CameraRotationSpeed.x * Time.deltaTime);
this.VerticalRotation += Input.GetAxis(yKey) * this.CameraRotationSpeed.y * Time.deltaTime;
this.VerticalRotation = Mathf.Clamp(this.VerticalRotation, this.CameraRotationConstraints.x, this.CameraRotationConstraints.y);
Camera.main.transform.eulerAngles = new Vector3(
-this.VerticalRotation,
Camera.main.transform.eulerAngles.y,
Camera.main.transform.eulerAngles.z
);
###Rotate()
In this method the only difference between the if
branches are the getting of the X
and Y
location. It would be enough to place getting these in the branches and therfor you could remove some of the duplicated code but it would be much better just assigning the string
's which are needed to two variables like so
var xKey = "Mouse X";
var yKey = "Mouse Y";
if(this.UseController)
{
xKey = "Xbox Look X";
yKey = "Xbox Look Y";
}
this.transform.Rotate(new Vector3(0.0f, Input.GetAxis(xKey), 0.0f) * this.CameraRotationSpeed.x * Time.deltaTime);
this.VerticalRotation += Input.GetAxis(yKey) * this.CameraRotationSpeed.y * Time.deltaTime;
this.VerticalRotation = Mathf.Clamp(this.VerticalRotation, this.CameraRotationConstraints.x, this.CameraRotationConstraints.y);
Camera.main.transform.eulerAngles = new Vector3(
-this.VerticalRotation,
Camera.main.transform.eulerAngles.y,
Camera.main.transform.eulerAngles.z
);
###Rotate()
In this method the only difference between the if
branches are the getting of the X
and Y
location. It would be enough to place getting these in the branches and therefor you could remove some of the duplicated code but it would be much better just assigning the string
's, which are needed, to two variables like so
var xKey = "Mouse X";
var yKey = "Mouse Y";
if(this.UseController)
{
xKey = "Xbox Look X";
yKey = "Xbox Look Y";
}
this.transform.Rotate(new Vector3(0.0f, Input.GetAxis(xKey), 0.0f) * this.CameraRotationSpeed.x * Time.deltaTime);
this.VerticalRotation += Input.GetAxis(yKey) * this.CameraRotationSpeed.y * Time.deltaTime;
this.VerticalRotation = Mathf.Clamp(this.VerticalRotation, this.CameraRotationConstraints.x, this.CameraRotationConstraints.y);
Camera.main.transform.eulerAngles = new Vector3(
-this.VerticalRotation,
Camera.main.transform.eulerAngles.y,
Camera.main.transform.eulerAngles.z
);
###Rotate()
In this method the only difference between the if
branches are the getting of the X
and Y
location. It would be enough to place getting these in the branches and therfor you could remove some of the duplicated code but it would be much better just assigning the string
's which are needed to two variables like so
var xKey = "Mouse X";
var yKey = "Mouse Y";
if(this.UseController)
{
xKey = "Xbox Look X";
yKey = "Xbox Look Y";
}
this.transform.Rotate(new Vector3(0.0f, Input.GetAxis(xKey), 0.0f) * this.CameraRotationSpeed.x * Time.deltaTime);
this.VerticalRotation += Input.GetAxis(yKey) * this.CameraRotationSpeed.y * Time.deltaTime;
this.VerticalRotation = Mathf.Clamp(this.VerticalRotation, this.CameraRotationConstraints.x, this.CameraRotationConstraints.y);
Camera.main.transform.eulerAngles = new Vector3(
-this.VerticalRotation,
Camera.main.transform.eulerAngles.y,
Camera.main.transform.eulerAngles.z
);