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

View File

@ -9,6 +9,7 @@ public class PlayerMoveScript : MonoBehaviour
public float xSensitivity; public float xSensitivity;
public float ySensitivity; public float ySensitivity;
private Rigidbody rb; private Rigidbody rb;
public Camera cam;
void Start() void Start()
{ {
@ -22,26 +23,31 @@ public class PlayerMoveScript : MonoBehaviour
int moveDirX = 0;; int moveDirX = 0;;
int moveDirZ = 0; int moveDirZ = 0;
if(Input.GetKey(KeyCode.W)){moveDirZ--;} if(Input.GetKey(KeyCode.W)){moveDirZ++;}
if(Input.GetKey(KeyCode.S)){moveDirZ++;} if(Input.GetKey(KeyCode.S)){moveDirZ--;}
if(Input.GetKey(KeyCode.D)){moveDirX--;} if(Input.GetKey(KeyCode.D)){moveDirX++;}
if(Input.GetKey(KeyCode.A)){moveDirX++;} if(Input.GetKey(KeyCode.A)){moveDirX--;}
Vector3 moveDir = new Vector3(moveDirX, 0, moveDirZ); Vector3 moveDir = new Vector3(moveDirX, 0, moveDirZ);
moveDir.Normalize(); moveDir.Normalize();
rb.velocity = transform.TransformDirection(new Vector3(moveDir.x * speed, rb.velocity.y, moveDir.z * speed)); rb.velocity = transform.TransformDirection(new Vector3(moveDir.x * speed, rb.velocity.y, moveDir.z * speed));
look();
} }
public void look() public void look()
{ {
//float xMouseMovement = Input.GetAxis("Mouse X") * xSensitivity * time.deltaTime; float xMouseMovement = Input.GetAxis("Mouse X") * xSensitivity * Time.deltaTime;
//float yMouseMovement = Input.GetAxis("Mouse Y") * ySensitivity * 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 newDirX = currentRotation.y + xMouseMovement;
//float newDirY = currentRotation.y + xMouseMovement; float newDirY = currentRotation.x - yMouseMovement;
cam.transform.rotation = Quaternion.Euler(0, newDirX, 0);
transform.rotation = Quaternion.Euler(newDirY, 0, 0);
} }
} }