PlayerMovementScript + CameraScript angefangen
This commit is contained in:
@@ -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<Rigidbody>();
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e02ea9a2e5b1a1d4295536c2a8b1353e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user