Umschauen bearbeitet, funkrioniert noch nicht
This commit is contained in:
@@ -9,6 +9,7 @@ public class PlayerMoveScript : MonoBehaviour
|
||||
public float xSensitivity;
|
||||
public float ySensitivity;
|
||||
private Rigidbody rb;
|
||||
public Camera cam;
|
||||
|
||||
void Start()
|
||||
{
|
||||
@@ -22,26 +23,31 @@ public class PlayerMoveScript : MonoBehaviour
|
||||
int moveDirX = 0;;
|
||||
int moveDirZ = 0;
|
||||
|
||||
if(Input.GetKey(KeyCode.W)){moveDirZ--;}
|
||||
if(Input.GetKey(KeyCode.S)){moveDirZ++;}
|
||||
if(Input.GetKey(KeyCode.D)){moveDirX--;}
|
||||
if(Input.GetKey(KeyCode.A)){moveDirX++;}
|
||||
if(Input.GetKey(KeyCode.W)){moveDirZ++;}
|
||||
if(Input.GetKey(KeyCode.S)){moveDirZ--;}
|
||||
if(Input.GetKey(KeyCode.D)){moveDirX++;}
|
||||
if(Input.GetKey(KeyCode.A)){moveDirX--;}
|
||||
|
||||
Vector3 moveDir = new Vector3(moveDirX, 0, moveDirZ);
|
||||
moveDir.Normalize();
|
||||
|
||||
rb.velocity = transform.TransformDirection(new Vector3(moveDir.x * speed, rb.velocity.y, moveDir.z * speed));
|
||||
|
||||
look();
|
||||
|
||||
}
|
||||
|
||||
public void look()
|
||||
{
|
||||
//float xMouseMovement = Input.GetAxis("Mouse X") * xSensitivity * time.deltaTime;
|
||||
//float yMouseMovement = Input.GetAxis("Mouse Y") * ySensitivity * time.deltaTime;
|
||||
float xMouseMovement = Input.GetAxis("Mouse X") * xSensitivity * Time.deltaTime;
|
||||
float yMouseMovement = Input.GetAxis("Mouse Y") * ySensitivity * Time.deltaTime;
|
||||
|
||||
//Vector3 currentRotation = playerCam.transform.localRotation.eulerAngles;
|
||||
Vector3 currentRotation = cam.transform.rotation.eulerAngles;
|
||||
|
||||
//float newDirX = currentRotation.y + xMouseMovement;
|
||||
//float newDirY = currentRotation.y + xMouseMovement;
|
||||
float newDirX = currentRotation.y + xMouseMovement;
|
||||
float newDirY = currentRotation.x - yMouseMovement;
|
||||
|
||||
cam.transform.rotation = Quaternion.Euler(0, newDirX, 0);
|
||||
transform.rotation = Quaternion.Euler(newDirY, 0, 0);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user