From fee185dffc9df9bb646392d586525359d6754bcd Mon Sep 17 00:00:00 2001 From: Jan Breitkreuz Date: Wed, 12 Jun 2024 13:00:57 +0200 Subject: [PATCH] PlayerMovementScript + CameraScript angefangen --- Plunderblock/Assets/Scenes/JanScene.unity | 16 +++++++ .../PlayerScripts/PlayerMoveScript.cs | 47 +++++++++++++++++++ .../PlayerScripts/PlayerMoveScript.cs.meta | 11 +++++ 3 files changed, 74 insertions(+) create mode 100644 Plunderblock/Assets/Scripts/ScriptsJan/PlayerScripts/PlayerMoveScript.cs create mode 100644 Plunderblock/Assets/Scripts/ScriptsJan/PlayerScripts/PlayerMoveScript.cs.meta diff --git a/Plunderblock/Assets/Scenes/JanScene.unity b/Plunderblock/Assets/Scenes/JanScene.unity index b12fc1a..f738f43 100644 --- a/Plunderblock/Assets/Scenes/JanScene.unity +++ b/Plunderblock/Assets/Scenes/JanScene.unity @@ -520,6 +520,7 @@ GameObject: - component: {fileID: 1314392193} - component: {fileID: 1314392192} - component: {fileID: 1314392191} + - component: {fileID: 1314392196} m_Layer: 0 m_Name: Player m_TagString: Untagged @@ -644,6 +645,21 @@ Transform: - {fileID: 1132902782} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: -90, z: 0} +--- !u!114 &1314392196 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1314392190} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e02ea9a2e5b1a1d4295536c2a8b1353e, type: 3} + m_Name: + m_EditorClassIdentifier: + speed: 2 + xSensitivity: 0 + ySensitivity: 0 --- !u!1 &1771553239 GameObject: m_ObjectHideFlags: 0 diff --git a/Plunderblock/Assets/Scripts/ScriptsJan/PlayerScripts/PlayerMoveScript.cs b/Plunderblock/Assets/Scripts/ScriptsJan/PlayerScripts/PlayerMoveScript.cs new file mode 100644 index 0000000..f52d8f9 --- /dev/null +++ b/Plunderblock/Assets/Scripts/ScriptsJan/PlayerScripts/PlayerMoveScript.cs @@ -0,0 +1,47 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class PlayerMoveScript : MonoBehaviour +{ + + public float speed; + public float xSensitivity; + public float ySensitivity; + private Rigidbody rb; + + void Start() + { + rb = GetComponent(); + } + + // Update is called once per frame + void Update() + { + // In welche Richtung rennt der Spieler? + 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++;} + + Vector3 moveDir = new Vector3(moveDirX, 0, moveDirZ); + moveDir.Normalize(); + + rb.velocity = transform.TransformDirection(new Vector3(moveDir.x * speed, rb.velocity.y, moveDir.z * speed)); + + } + + public void look() + { + //float xMouseMovement = Input.GetAxis("Mouse X") * xSensitivity * time.deltaTime; + //float yMouseMovement = Input.GetAxis("Mouse Y") * ySensitivity * time.deltaTime; + + //Vector3 currentRotation = playerCam.transform.localRotation.eulerAngles; + + //float newDirX = currentRotation.y + xMouseMovement; + //float newDirY = currentRotation.y + xMouseMovement; + } +} diff --git a/Plunderblock/Assets/Scripts/ScriptsJan/PlayerScripts/PlayerMoveScript.cs.meta b/Plunderblock/Assets/Scripts/ScriptsJan/PlayerScripts/PlayerMoveScript.cs.meta new file mode 100644 index 0000000..df7bebd --- /dev/null +++ b/Plunderblock/Assets/Scripts/ScriptsJan/PlayerScripts/PlayerMoveScript.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e02ea9a2e5b1a1d4295536c2a8b1353e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: