Umschauen bearbeitet, funkrioniert noch nicht

This commit is contained in:
Jan Breitkreuz 2024-06-13 12:42:36 +02:00
parent 8e086fdeb5
commit 5116a25e02
2 changed files with 21 additions and 14 deletions

View File

@ -492,7 +492,7 @@ Camera:
field of view: 60
orthographic: 0
orthographic size: 5
m_Depth: -2
m_Depth: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
@ -658,8 +658,9 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
speed: 2
xSensitivity: 0
ySensitivity: 0
xSensitivity: 200
ySensitivity: 200
cam: {fileID: 1132902784}
--- !u!1 &1771553239
GameObject:
m_ObjectHideFlags: 0
@ -678,7 +679,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!4 &1771553240
Transform:
m_ObjectHideFlags: 0
@ -688,7 +689,7 @@ Transform:
m_GameObject: {fileID: 1771553239}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0.401, z: -0.305}
m_LocalPosition: {x: 0, y: 0.401, z: 0.29}
m_LocalScale: {x: 0.7, y: 0.5, z: 0.5}
m_ConstrainProportionsScale: 0
m_Children: []

View File

@ -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);
}
}