Skip to main content
Code Review

Return to Answer

Commonmark migration
Source Link

###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
 );
added 3 characters in body
Source Link
Heslacher
  • 50.9k
  • 5
  • 83
  • 177

###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
 );
Source Link
Heslacher
  • 50.9k
  • 5
  • 83
  • 177

###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
 );
lang-cs

AltStyle によって変換されたページ (->オリジナル) /