feat: scene built, basic function completed
This commit is contained in:
18
Assets/scripts/CameraControllerX.cs
Normal file
18
Assets/scripts/CameraControllerX.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CameraControllerX : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private float mouseSpeed = 20f;
|
||||
|
||||
void Update()
|
||||
{
|
||||
float mouseX = Input.GetAxis("Mouse X");
|
||||
|
||||
transform.Rotate(Vector3.up * (mouseX * mouseSpeed));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
3
Assets/scripts/CameraControllerX.cs.meta
Normal file
3
Assets/scripts/CameraControllerX.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 54f70d5af29a406987058ba50db0a636
|
||||
timeCreated: 1783053068
|
||||
24
Assets/scripts/CameraControllerY.cs
Normal file
24
Assets/scripts/CameraControllerY.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CameraControllerY : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private float mouseSpeed = 500f;
|
||||
|
||||
private float pitch = 0f;
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
float mouseY = Input.GetAxis("Mouse Y");
|
||||
|
||||
pitch -= mouseY * mouseSpeed * Time.deltaTime;
|
||||
|
||||
pitch = Mathf.Clamp(pitch, -90f, 30f);
|
||||
|
||||
transform.localRotation = Quaternion.Euler(pitch, 0f, 0f);
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/scripts/CameraControllerY.cs.meta
Normal file
11
Assets/scripts/CameraControllerY.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d5fcaeb18225e04419f9a3d6c48546a5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,52 +1,59 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Moving : MonoBehaviour
|
||||
{
|
||||
|
||||
|
||||
public float speed = 5f;
|
||||
[SerializeField]
|
||||
private Rigidbody rb;
|
||||
|
||||
[SerializeField]
|
||||
private float jumpForce = 5f;
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
Vector3 direction = Vector3.zero;
|
||||
|
||||
if (Input.GetKey(KeyCode.W))
|
||||
direction += Vector3.forward;
|
||||
|
||||
if (Input.GetKey(KeyCode.S))
|
||||
direction += Vector3.back;
|
||||
|
||||
if (Input.GetKey(KeyCode.A))
|
||||
direction += Vector3.left;
|
||||
|
||||
if (Input.GetKey(KeyCode.D))
|
||||
direction += Vector3.right;
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
rb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
|
||||
|
||||
if (Input.GetKey(KeyCode.LeftControl))
|
||||
Debug.Log("left ctrl active");
|
||||
|
||||
|
||||
direction = direction.normalized;
|
||||
|
||||
transform.position += direction * (speed * Time.deltaTime);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Moving : MonoBehaviour
|
||||
{
|
||||
|
||||
|
||||
public float speed = 5f;
|
||||
[SerializeField]
|
||||
private Rigidbody rb;
|
||||
|
||||
[SerializeField]
|
||||
private float jumpForce = 5f;
|
||||
|
||||
|
||||
void Awake(){
|
||||
rb = GetComponent<Rigidbody>();
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
Vector3 direction = Vector3.zero;
|
||||
|
||||
if (Input.GetKey(KeyCode.W))
|
||||
direction += Vector3.forward;
|
||||
|
||||
if (Input.GetKey(KeyCode.S))
|
||||
direction += Vector3.back;
|
||||
|
||||
if (Input.GetKey(KeyCode.A))
|
||||
direction += Vector3.left;
|
||||
|
||||
if (Input.GetKey(KeyCode.D))
|
||||
direction += Vector3.right;
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
rb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
|
||||
|
||||
if (Input.GetKey(KeyCode.LeftControl))
|
||||
Debug.Log("left ctrl active");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
direction = direction.normalized;
|
||||
|
||||
transform.position += direction * (speed * Time.deltaTime);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user